From 240950c9df43688b59585920a6688bbe8a5807dd Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 9 Dec 2010 20:43:43 +0000 Subject: Less code. git-svn-id: http://svn.drobilla.net/resp/resp@330 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/expand.cpp | 34 +++++++++++----------------------- 1 file 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); } -- cgit v1.2.1