コード例 #1
0
        public DerpInterpreter()
        {
            callStack = new List <SExpression>();
            e         = new Environment();
            parser    = new DerpParser("");

            e.addVal("+", new SPrimitive(SAdd, false, 0));
            e.addVal("*", new SPrimitive(SMult, false, 0));
            e.addVal("/", new SPrimitive(SDiv, true, 2));
            e.addVal("-", new SPrimitive(SSub, false, 0));
            e.addVal("mod", new SPrimitive(SMod, true, 2));
            e.addVal("if", new SPrimitive(SIf, true, 3, false));
            e.addVal("let", new SPrimitive(SLet, false, 0, false));
            e.addVal("define", new SPrimitive(SDefine, true, 2, false));
            e.addVal("lambda", new SPrimitive(SLambda, true, 2, false));
            e.addVal("debug", new SPrimitive(SDebug, true, 1));
            e.addVal("list", new SPrimitive(SList, false, 0));
            e.addVal("cons", new SPrimitive(SCons, true, 2));
            e.addVal("car", new SPrimitive(SCar, true, 1));
            e.addVal("cdr", new SPrimitive(SCdr, true, 1));
            e.addVal("null?", new SPrimitive(SNullList, true, 1));
            e.addVal("=", new SPrimitive(SEq, true, 2));
            e.addVal(">", new SPrimitive(SGt, true, 2));
            e.addVal("<", new SPrimitive(SLt, true, 2));
            e.addVal("begin", new SPrimitive(SBegin, false, 0));
            e.addVal("typeof", new SPrimitive(TypeOf, false, 1));
            e.addVal("eval", new SPrimitive(Eval, false, 1));
        }
コード例 #2
0
 public DerpParser(string initialText)
 {
     parseStack = new List <List <SExpression> >();
     tokens     = DerpParser.Tokenize(initialText);
     parseStack.Add(new List <SExpression>());
 }