diff options
author | David Robillard <d@drobilla.net> | 2010-12-09 20:43:43 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-09 20:43:43 +0000 |
commit | 240950c9df43688b59585920a6688bbe8a5807dd (patch) | |
tree | cfe2614fd9b968c983867380aa15ed8843d856cb | |
parent | 7f7d76ec1719db97d94adeae8b31b0c9e6c11d92 (diff) | |
download | resp-240950c9df43688b59585920a6688bbe8a5807dd.tar.gz resp-240950c9df43688b59585920a6688bbe8a5807dd.tar.bz2 resp-240950c9df43688b59585920a6688bbe8a5807dd.zip |
Less code.
git-svn-id: http://svn.drobilla.net/resp/resp@330 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-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); } |