diff options
Diffstat (limited to 'tuplr.cpp')
-rw-r--r-- | tuplr.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -123,10 +123,15 @@ parseLiteral(PEnv& penv, const SExp& exp, void* arg) inline AST* parseFn(PEnv& penv, const SExp& exp, void* arg) { + if (exp.list.size() < 2) + throw Error("Missing function parameters and body", exp.loc); + else if (exp.list.size() < 3) + throw Error("Missing function body", exp.loc); SExp::List::const_iterator a = exp.list.begin(); ++a; - return new AClosure(exp.loc, penv.sym("fn"), - new ATuple(penv.parseTuple(*a++)), - penv.parse(*a++)); + AClosure* ret = new AClosure(exp.loc, penv.sym("fn"), new ATuple(penv.parseTuple(*a++))); + while (a != exp.list.end()) + ret->push_back(penv.parse(*a++)); + return ret; } @@ -200,6 +205,7 @@ main(int argc, char** argv) initLang(penv, tenv); CEnv* cenv = newCenv(penv, tenv); + cenv->push(); map<string,string> args; list<string> files; |