aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ll.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/ll.cpp b/ll.cpp
index e6822c6..eb8708a 100644
--- a/ll.cpp
+++ b/ll.cpp
@@ -48,21 +48,23 @@ struct Error : public std::exception {
const char* msg;
};
+template<typename A>
+struct Exp { // ::= Atom | (Exp*)
+ Exp() : type(LIST) {}
+ Exp(const std::list<Exp>& l) : type(LIST), list(l) {}
+ Exp(const A& a) : type(ATOM), atom(a) {}
+ enum { ATOM, LIST } type;
+ A atom;
+ std::list< Exp<A> > list;
+};
+
/***************************************************************************
* S-Expression Lexer :: text -> S-Expressions (SExp) *
***************************************************************************/
struct SyntaxError : public Error { SyntaxError(const char* m) : Error(m) {} };
-
-struct SExp {
- SExp() : type(LIST) {}
- SExp(const std::list<SExp>& l) : type(LIST), list(l) {}
- SExp(const std::string& s) : type(ATOM), atom(s) {}
- enum { ATOM, LIST } type;
- std::string atom;
- std::list<SExp> list;
-};
+typedef Exp<string> SExp;
static SExp
readExpression(std::istream& in)
@@ -461,7 +463,7 @@ ASTCall::constrain(TEnv& tenv) const
{
FOREACH(TupV::const_iterator, p, tup)
(*p)->constrain(tenv);
- AType* retT = tenv.type(this);
+ AType* retT = tenv.type(this);
TupV texp = tuple(tenv.penv.sym("Fn"), tenv.var(), retT, NULL);
tenv.constrain(tup[0], new AType(texp));
}