diff options
Diffstat (limited to 'src/resp.hpp')
-rw-r--r-- | src/resp.hpp | 59 |
1 files changed, 7 insertions, 52 deletions
diff --git a/src/resp.hpp b/src/resp.hpp index d9c85fe..dd5987a 100644 --- a/src/resp.hpp +++ b/src/resp.hpp @@ -544,57 +544,6 @@ struct ACall : public ATuple { void constrain(TEnv& tenv, Constraints& c) const throw(Error); }; -/// Definition special form, e.g. "(def x 2)" -struct ADef : public ACall { - ADef(const ATuple* exp) : ACall(exp) {} - ADef(Cursor c, AST* ast, va_list args) : ACall(c, ast, args) {} - ADef(AST* first, AST* rest, Cursor c) : ACall(first, rest, c) {} -}; - -struct ADefType : public ACall { - ADefType(const ATuple* exp) : ACall(exp) {} - ADefType(Cursor c, AST* ast, va_list args) : ACall(c, ast, args) {} - ADefType(AST* first, AST* rest, Cursor c) : ACall(first, rest, c) {} -}; - -struct AMatch : public ACall { - AMatch(const ATuple* exp) : ACall(exp) {} - AMatch(Cursor c, AST* ast, va_list args) : ACall(c, ast, args) {} - AMatch(AST* first, AST* rest, Cursor c) : ACall(first, rest, c) {} -}; - -/// Conditional special form, e.g. "(if cond thenexp elseexp)" -struct AIf : public ACall { - AIf(const ATuple* exp) : ACall(exp) {} - AIf(Cursor c, AST* ast, va_list args) : ACall(c, ast, args) {} - AIf(AST* first, AST* rest, Cursor c) : ACall(first, rest, c) {} -}; - -struct ACons : public ACall { - ACons(const ATuple* exp) : ACall(exp) {} - ACons(Cursor c, AST* ast, va_list args) : ACall(c, ast, args) {} - ACons(AST* first, AST* rest, Cursor c) : ACall(first, rest, c) {} -}; - -struct ADot : public ACall { - ADot(const ATuple* exp) : ACall(exp) {} - ADot(Cursor c, AST* ast, va_list args) : ACall(c, ast, args) {} - ADot(AST* first, AST* rest, Cursor c) : ACall(first, rest, c) {} -}; - -/// Primitive (builtin arithmetic function), e.g. "(+ 2 3)" -struct APrimitive : public ACall { - APrimitive(const ATuple* exp) : ACall(exp) {} - APrimitive(AST* first, AST* rest, Cursor c) : ACall(first, rest, c) {} - void constrain(TEnv& tenv, Constraints& c) const throw(Error); -}; - -struct AQuote : public ACall { - AQuote(const ATuple* exp) : ACall(exp) {} - AQuote(AST* first, AST* rest, Cursor c) : ACall(first, rest, c) {} - AQuote(Cursor c, AST* ast, va_list args) : ACall(c, ast, args) {} -}; - /*************************************************************************** * Parser: S-Expressions (SExp) -> AST Nodes (AST) * @@ -637,6 +586,10 @@ struct PEnv : private map<const string, ASymbol*> { } } AST* parse(const AST* exp); + + typedef std::set<std::string> Primitives; + Primitives primitives; + unsigned symID; }; @@ -785,7 +738,7 @@ struct Engine { virtual CVal compileLiteral(CEnv& cenv, const AST* lit) = 0; virtual CVal compileString(CEnv& cenv, const char* str) = 0; virtual CVal compileCall(CEnv& cenv, CFunc f, const AType* fT, ValVec& args) = 0; - virtual CVal compilePrimitive(CEnv& cenv, const APrimitive* prim) = 0; + virtual CVal compilePrimitive(CEnv& cenv, const ACall* prim) = 0; virtual CVal compileIf(CEnv& cenv, const ACall* aif) = 0; virtual CVal compileMatch(CEnv& cenv, const ACall* match) = 0; virtual CVal compileGlobal(CEnv& cenv, const AType* t, const string& sym, CVal val) = 0; @@ -906,5 +859,7 @@ int eval(CEnv& cenv, Cursor& cursor, istream& is, bool execute); int repl(CEnv& cenv); AST* resp_lift(CEnv& cenv, Code& code, AST* ast) throw(); CVal resp_compile(CEnv& cenv, const AST* ast) throw(); +bool is_form(const AST* ast, const std::string& form); +bool is_primitive(const PEnv& penv, const AST* ast); #endif // RESP_HPP |