aboutsummaryrefslogtreecommitdiffstats
path: root/tuplr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tuplr.cpp')
-rw-r--r--tuplr.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/tuplr.cpp b/tuplr.cpp
index bfd6192..3429a9f 100644
--- a/tuplr.cpp
+++ b/tuplr.cpp
@@ -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;