diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/expand.cpp (renamed from src/parse.cpp) | 29 | ||||
-rw-r--r-- | src/repl.cpp | 2 | ||||
-rw-r--r-- | src/resp.cpp | 2 | ||||
-rw-r--r-- | src/resp.hpp | 2 |
4 files changed, 17 insertions, 18 deletions
diff --git a/src/parse.cpp b/src/expand.cpp index 3fb8375..8e682dd 100644 --- a/src/parse.cpp +++ b/src/expand.cpp @@ -23,17 +23,17 @@ using namespace std; -const ATuple* -parseList(PEnv& penv, const ATuple* e) +static inline const ATuple* +expand_list(PEnv& penv, const ATuple* e) { List<ATuple, const AST> ret; FOREACHP(ATuple::const_iterator, i, e) - ret.push_back(penv.parse(*i)); + ret.push_back(penv.expand(*i)); return ret.head; } -inline const AST* -parseFn(PEnv& penv, const AST* exp, void* arg) +static inline const AST* +expand_fn(PEnv& penv, const AST* exp, void* arg) { const ATuple* tup = exp->to_tuple(); ATuple::const_iterator a = tup->begin(); @@ -43,12 +43,12 @@ parseFn(PEnv& penv, const AST* exp, void* arg) List<ATuple, const AST> ret(new ATuple(penv.sym("fn"), NULL, exp->loc)); ret.push_back(prot); while (a != tup->end()) - ret.push_back(penv.parse(*a++)); + ret.push_back(penv.expand(*a++)); return ret.head; } -inline const AST* -parseDef(PEnv& penv, const AST* exp, void* arg) +static inline const AST* +expand_def(PEnv& penv, const AST* exp, void* arg) { const ATuple* tup = exp->as_tuple(); @@ -57,7 +57,7 @@ parseDef(PEnv& penv, const AST* exp, void* arg) const AST* arg1 = *(++i); THROW_IF(i == tup->end(), arg1->loc, "Unexpected end of `def' form"); if (arg1->to_symbol()) { - return parseList(penv, tup); + return expand_list(penv, tup); } else { // (def (f x) y) => (def f (fn (x) y)) const ATuple* pat = arg1->to_tuple(); @@ -82,12 +82,12 @@ parseDef(PEnv& penv, const AST* exp, void* arg) ret.push_back(fnExp.head); ret.head->loc = exp->loc; - return parseList(penv, ret.head); + return expand_list(penv, ret.head); } } const AST* -PEnv::parse(const AST* exp) +PEnv::expand(const AST* exp) { const ATuple* tup = exp->to_tuple(); if (!tup) @@ -96,15 +96,14 @@ PEnv::parse(const AST* exp) THROW_IF(tup->empty(), exp->loc, "Call to empty list"); if (is_form(tup, "def")) - return parseDef(*this, exp, NULL); + return expand_def(*this, exp, NULL); else if (is_form(tup, "fn")) - return parseFn(*this, exp, NULL); + return expand_fn(*this, exp, NULL); else - return parseList(*this, tup); + return expand_list(*this, tup); } - /*************************************************************************** * Language Definition * ***************************************************************************/ diff --git a/src/repl.cpp b/src/repl.cpp index 8b4faab..965e202 100644 --- a/src/repl.cpp +++ b/src/repl.cpp @@ -39,7 +39,7 @@ readParseType(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, const AST*& as if (!exp || (exp->to_tuple() && exp->to_tuple()->empty())) return false; - ast = cenv.penv.parse(exp); // Parse input + ast = cenv.penv.expand(exp); // Parse input Constraints c(cenv.tsubst); resp_constrain(cenv.tenv, c, ast); // Constrain types diff --git a/src/resp.cpp b/src/resp.cpp index 824acff..9e959f5 100644 --- a/src/resp.cpp +++ b/src/resp.cpp @@ -147,7 +147,7 @@ main(int argc, char** argv) if (!exp || (exp->to_tuple() && exp->to_tuple()->tup_len() == 1)) break; - const AST* ast = penv.parse(exp); + const AST* ast = penv.expand(exp); pprint(os, ast, cenv, false); is.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // Skip newlines } diff --git a/src/resp.hpp b/src/resp.hpp index 77f771c..ae7bc11 100644 --- a/src/resp.hpp +++ b/src/resp.hpp @@ -557,7 +557,7 @@ struct PEnv : private map<const string, ASymbol*> { return sym; } } - const AST* parse(const AST* exp); + const AST* expand(const AST* exp); typedef std::set<std::string> Primitives; Primitives primitives; |