Example #1
0
 private object Dispatch(object expr, Environment env)
 {
     if (_capEx != null)
     {
         CaptureException capEx = _capEx;
         _capEx = null;
         if (capEx.Continuation == null)
         {
             capEx.AddContext(new HaltContext());
         }
         Continuation k = new Continuation(capEx.Continuation);
         return(ResumeWithProcedure(capEx.Continuation,
                                    capEx.Procedure, k));
     }
     else if (_invEx != null)
     {
         InvokeException invEx = _invEx;
         _invEx = null;
         return(ResumeWithValue(invEx.Continuation, invEx.ReturnValue));
     }
     else
     {
         return(Execute(expr, Pair.EmptyList, env));
     }
 }
Example #2
0
        public Interpreter(TextReader reader)
        {
            StandardLibrary sl = StandardLibrary.Instance();

            _globalEnv = new Environment(sl.Symbols, sl.Values);
            _compiler  = new Compiler(new MacroExpander(new Parser(
                                                            new Scanner(reader)), this));
            _capEx = null;
            _invEx = null;
        }
Example #3
0
 private object Evaluate(object expr, Environment env)
 {
     for (;;)
     {
         try {
             return(Dispatch(expr, env));
         } catch (CaptureException captureEx) {
             _capEx = captureEx;
         } catch (InvokeException invEx) {
             _invEx = invEx;
         }
     }
 }