diff options
Diffstat (limited to 'src/repl.cpp')
-rw-r--r-- | src/repl.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/repl.cpp b/src/repl.cpp index 0ec644c..7ef7ff3 100644 --- a/src/repl.cpp +++ b/src/repl.cpp @@ -27,7 +27,7 @@ using namespace std; static bool -readParseType(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, AST*& ast) +readParseType(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, const AST*& ast) { try { exp = readExpression(cursor, is); @@ -65,7 +65,7 @@ readParseType(CEnv& cenv, Cursor& cursor, istream& is, AST*& exp, AST*& ast) } static void -callPrintCollect(CEnv& cenv, CFunc f, AST* result, const AType* resultT, bool execute) +callPrintCollect(CEnv& cenv, CFunc f, const AST* result, const AType* resultT, bool execute) { if (execute) cenv.out << cenv.engine()->call(cenv, f, resultT); @@ -82,14 +82,17 @@ int eval(CEnv& cenv, Cursor& cursor, istream& is, bool execute) { AST* exp = NULL; - AST* ast = NULL; - list<AST*> parsed; + const AST* ast = NULL; + + typedef list<const AST*> Parsed; + Parsed parsed; + try { while (readParseType(cenv, cursor, is, exp, ast)) parsed.push_back(ast); if (cenv.args.find("-T") != cenv.args.end()) { - for (list<AST*>::const_iterator i = parsed.begin(); i != parsed.end(); ++i) + for (Parsed::const_iterator i = parsed.begin(); i != parsed.end(); ++i) pprint(cout, *i, &cenv, true); return 0; } @@ -99,10 +102,10 @@ eval(CEnv& cenv, Cursor& cursor, istream& is, bool execute) // Lift all expressions Code lifted; - for (list<AST*>::iterator i = parsed.begin(); i != parsed.end(); ++i) { - AST* l = resp_lift(cenv, lifted, *i); + for (Parsed::const_iterator i = parsed.begin(); i != parsed.end(); ++i) { + const AST* l = resp_lift(cenv, lifted, *i); if (l) - lifted.push_back(l); + lifted.push_back(const_cast<AST*>(l)); } if (cenv.args.find("-L") != cenv.args.end()) { @@ -158,7 +161,7 @@ int repl(CEnv& cenv) { AST* exp = NULL; - AST* ast = NULL; + const AST* ast = NULL; const string replFnName = cenv.penv.gensymstr("_repl"); while (1) { cenv.out << "() "; |