aboutsummaryrefslogtreecommitdiffstats
path: root/tuplr.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'tuplr.hpp')
-rw-r--r--tuplr.hpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/tuplr.hpp b/tuplr.hpp
index cc0b086..8afcee7 100644
--- a/tuplr.hpp
+++ b/tuplr.hpp
@@ -72,7 +72,7 @@ struct Exp {
/***************************************************************************
- * Lexer: Text (istream) -> S-Expressions (SExp) (Prefix S for Syntactic) *
+ * Lexer: Text (istream) -> S-Expressions (SExp) *
***************************************************************************/
typedef Exp<string> SExp; ///< Textual S-Expression
@@ -81,12 +81,12 @@ SExp readExpression(Cursor& cur, std::istream& in);
/***************************************************************************
- * Backend (Prefix C for Compiled) *
+ * Backend *
***************************************************************************/
typedef void* CValue; ///< Compiled value (opaque)
typedef void* CFunction; ///< Compiled function (opaque)
-struct CEngine; ///< Backend data (opaque)
+typedef void* CEngine; ///< Compiler Engine (opaque)
/***************************************************************************
@@ -298,10 +298,10 @@ struct ACdrCall : public ACall {
/***************************************************************************
- * Parser: S-Expressions (SExp) -> AST Nodes (AST) (Prefix P for Parsing) *
+ * Parser: S-Expressions (SExp) -> AST Nodes (AST) *
***************************************************************************/
-/// Parse Time Environment (symbol table)
+/// Parse Time Environment (really just a symbol table)
struct PEnv : private map<const string, ASymbol*> {
typedef AST* (*PF)(PEnv&, const SExp&, void*); // Parse Function
struct Handler { Handler(PF f, void* a=0) : func(f), arg(a) {} PF func; void* arg; };
@@ -403,7 +403,7 @@ struct Env : public list< map<K,V> > {
/***************************************************************************
- * Typing (Prefix T for Type) *
+ * Typing *
***************************************************************************/
/// Type-Time Environment
@@ -445,21 +445,21 @@ struct TEnv : public Env<const AST*,AType*> {
/// Compile-Time Environment
struct CEnv {
- CEnv(PEnv& p, TEnv& t, CEngine& e, ostream& os=std::cout, ostream& es=std::cerr);
+ CEnv(PEnv& p, TEnv& t, CEngine e, ostream& os=std::cout, ostream& es=std::cerr);
~CEnv();
typedef Env<const ASymbol*, AST*> Code;
typedef Env<const AST*, CValue> Vals;
- string gensym(const char* s="_") { return (format("%s%d") % s % symID++).str(); }
- void push() { code.push(); vals.push(); }
- void pop() { code.pop(); vals.pop(); }
- void precompile(AST* obj, CValue value) { vals.def(obj, value); }
- CValue compile(AST* obj);
- void optimise(CFunction f);
- void write(std::ostream& os);
+ CEngine engine();
+ string gensym(const char* s="_") { return (format("%s%d") % s % symID++).str(); }
+ void push() { code.push(); vals.push(); }
+ void pop() { code.pop(); vals.pop(); }
+ void precompile(AST* obj, CValue value) { vals.def(obj, value); }
+ CValue compile(AST* obj);
+ void optimise(CFunction f);
+ void write(std::ostream& os);
- CEngine& engine;
PEnv& penv;
TEnv tenv;
Code code;
@@ -478,7 +478,6 @@ private:
* EVAL/REPL/MAIN *
***************************************************************************/
-void initTypes(PEnv& penv, TEnv& tenv);
void initLang(PEnv& penv, TEnv& tenv);
CEnv* newCenv(PEnv& penv, TEnv& tenv);
int eval(CEnv& cenv, const string& name, istream& is);