diff options
Diffstat (limited to 'tuplr.hpp')
-rw-r--r-- | tuplr.hpp | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -50,10 +50,10 @@ struct Cursor { /// Compiler error struct Error { - Error(const string& m, Cursor c) : msg(m), loc(c) {} + Error(Cursor c, const string& m) : loc(c), msg(m) {} const string what() const { return (loc ? loc.str() + ": " : "") + "error: " + msg; } - string msg; Cursor loc; + string msg; }; /// Expression ::= Atom | (SubExp*) @@ -160,7 +160,7 @@ struct AST { template<typename T> T to() const { return dynamic_cast<T>(this); } template<typename T> T as() { T t = dynamic_cast<T>(this); - if (!t) throw Error("internal error: bad cast", loc); + if (!t) throw Error(loc, "internal error: bad cast"); return t; } Cursor loc; @@ -220,7 +220,7 @@ struct ATuple : public AST, public vector<AST*> { return false; } void constrain(TEnv& tenv, Constraints& c) const; - CValue compile(CEnv& cenv) { throw Error("tuple compiled", loc); } + CValue compile(CEnv& cenv) { throw Error(loc, "tuple compiled"); } }; /// Type Expression, e.g. "Int", "(Fn (Int Int) Float)" @@ -414,7 +414,7 @@ struct PEnv : private map<const string, ASymbol*> { } AST* parse(const SExp& exp) { if (exp.type == SExp::LIST) { - if (exp.empty()) throw Error("call to empty list", exp.loc); + if (exp.empty()) throw Error(exp.loc, "call to empty list"); if (exp.front().type == SExp::ATOM) { MF mf = mac(exp.front().atom); SExp expanded = (mf ? mf(*this, exp) : exp); |