diff options
Diffstat (limited to 'src/expand.cpp')
-rw-r--r-- | src/expand.cpp | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/src/expand.cpp b/src/expand.cpp index 8e682dd..e38c5bf 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -112,27 +112,15 @@ void initLang(PEnv& penv, TEnv& tenv) { // Types - tenv.def(penv.sym("Bool"), new AType(penv.sym("Bool"), AType::PRIM)); - tenv.def(penv.sym("Float"), new AType(penv.sym("Float"), AType::PRIM)); - tenv.def(penv.sym("Int"), new AType(penv.sym("Int"), AType::PRIM)); - tenv.def(penv.sym("Lexeme"), new AType(penv.sym("Lexeme"), AType::PRIM)); - tenv.def(penv.sym("Nothing"), new AType(penv.sym("Nothing"), AType::PRIM)); - tenv.def(penv.sym("Quote"), new AType(penv.sym("Quote"), AType::PRIM)); - tenv.def(penv.sym("String"), new AType(penv.sym("String"), AType::PRIM)); - - // Numeric primitives - penv.primitives.insert("+"); - penv.primitives.insert("-"); - penv.primitives.insert("*"); - penv.primitives.insert("/"); - penv.primitives.insert("%"); - penv.primitives.insert("and"); - penv.primitives.insert("or"); - penv.primitives.insert("xor"); - penv.primitives.insert("="); - penv.primitives.insert("!="); - penv.primitives.insert(">"); - penv.primitives.insert(">="); - penv.primitives.insert("<"); - penv.primitives.insert("<="); + const char* types[] = { + "Bool", "Float", "Int", "Lexeme", "Nothing", "Quote", "String", 0 }; + for (const char** t = types; *t; ++t) { + const ASymbol* sym = penv.sym(*t); + tenv.def(sym, new AType(sym, AType::PRIM)); + } + + const char* primitives[] = { + "+", "-", "*", "/", "%", "and", "or", "xor", "=", "!=", ">", ">=", "<", "<=", 0 }; + for (const char** p = primitives; *p; ++p) + penv.primitives.insert(*p); } |