aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-12-09 04:08:51 +0000
committerDavid Robillard <d@drobilla.net>2010-12-09 04:08:51 +0000
commitc27e97b2294951e5db6e9c9fa6f6f0de2c5243e6 (patch)
tree076d0121abfd7c38914cb666e239672389b11a25 /src
parentf8bb745beb481846e715cd1e455b3d688fe34d65 (diff)
downloadresp-c27e97b2294951e5db6e9c9fa6f6f0de2c5243e6.tar.gz
resp-c27e97b2294951e5db6e9c9fa6f6f0de2c5243e6.tar.bz2
resp-c27e97b2294951e5db6e9c9fa6f6f0de2c5243e6.zip
read_expression => PEnv::parse.
git-svn-id: http://svn.drobilla.net/resp/resp@325 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src')
-rw-r--r--src/parse.cpp10
-rw-r--r--src/repl.cpp2
-rw-r--r--src/resp.cpp2
-rw-r--r--src/resp.hpp12
4 files changed, 10 insertions, 16 deletions
diff --git a/src/parse.cpp b/src/parse.cpp
index e0948fe..8b563cf 100644
--- a/src/parse.cpp
+++ b/src/parse.cpp
@@ -95,7 +95,7 @@ read_list(PEnv& penv, Cursor& cur, istream& in)
eat_char(cur, in, ')');
return list.head;
} else {
- list.push_back(read_expression(penv, cur, in));
+ list.push_back(penv.parse(cur, in));
}
}
assert(false);
@@ -156,7 +156,7 @@ read_symbol(PEnv& penv, Cursor& cur, istream& in)
/// Read an expression from @a in
const AST*
-read_expression(PEnv& penv, Cursor& cur, istream& in)
+PEnv::parse(Cursor& cur, istream& in)
{
while (!cin.eof()) {
skip_space(cur, in);
@@ -170,7 +170,7 @@ read_expression(PEnv& penv, Cursor& cur, istream& in)
case '"':
return read_string(cur, in);
case '(':
- return read_list(penv, cur, in);
+ return read_list(*this, cur, in);
case ')':
throw Error(cur, "unexpected `)'");
case '#':
@@ -188,13 +188,13 @@ read_expression(PEnv& penv, Cursor& cur, istream& in)
return read_number(cur, in);
} else {
in.putback(c);
- return read_symbol(penv, cur, in);
+ return read_symbol(*this, cur, in);
}
default:
if (isdigit(c))
return read_number(cur, in);
else
- return read_symbol(penv, cur, in);
+ return read_symbol(*this, cur, in);
}
}
return NULL;
diff --git a/src/repl.cpp b/src/repl.cpp
index 114ff58..88fefab 100644
--- a/src/repl.cpp
+++ b/src/repl.cpp
@@ -30,7 +30,7 @@ static bool
readParseType(CEnv& cenv, Cursor& cursor, istream& is, const AST*& exp, const AST*& ast)
{
try {
- exp = read_expression(cenv.penv, cursor, is);
+ exp = cenv.penv.parse(cursor, is);
} catch (Error e) {
is.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // Skip REPL junk
throw e;
diff --git a/src/resp.cpp b/src/resp.cpp
index cef2d0c..49c4643 100644
--- a/src/resp.cpp
+++ b/src/resp.cpp
@@ -143,7 +143,7 @@ main(int argc, char** argv)
try {
while (is.good() && !is.eof()) {
Cursor loc(*f);
- const AST* exp = read_expression(cenv->penv, loc, is);
+ const AST* exp = cenv->penv.parse(loc, is);
if (!exp || (exp->to_tuple() && exp->to_tuple()->tup_len() == 1))
break;
diff --git a/src/resp.hpp b/src/resp.hpp
index a453b88..1fbf3cf 100644
--- a/src/resp.hpp
+++ b/src/resp.hpp
@@ -69,15 +69,6 @@ struct Error {
/***************************************************************************
- * Lexer: Text (istream) -> S-Expressions (SExp) *
- ***************************************************************************/
-
-struct PEnv;
-struct AST;
-const AST* read_expression(PEnv& penv, Cursor& cur, std::istream& in);
-
-
-/***************************************************************************
* Backend Types *
***************************************************************************/
@@ -544,6 +535,7 @@ ostream& operator<<(ostream& out, const Env<V>& env) {
return out;
}
+
/***************************************************************************
* Parser: S-Expressions (SExp) -> AST Nodes (AST) *
***************************************************************************/
@@ -564,6 +556,8 @@ struct PEnv : private map<const string, const char*> {
return new ASymbol(str, c);
}
}
+
+ const AST* parse(Cursor& cur, std::istream& in);
const AST* expand(const AST* exp);
typedef std::set<std::string> Primitives;