Пример #1
0
 public Lexer(SourceReader reader)
 {
     mReader = reader;
     mBeginningOfLine = false;
     mBeginningOfBlock = false;
     mOffsideLines = new Stack<int>();
     mOffsideLines.Push(1);
 }
Пример #2
0
 private bool Interpret(SourceReader reader, bool interactive)
 {
     try
     {
         Lexer lexer = new Lexer(reader);
         Parser parser = new Parser(lexer);
         while (true)
         {
             ISList<IInsn> insns = Compile(parser);
             if (insns == null)
             {
                 return false;
             }
             IValue result = Run(insns);
             if (result == null)
             {
                 return false;
             }
             if (interactive)
             {
                 Console.WriteLine(" => {0}", result);
             }
         }
     }
     catch (EndOfStreamException)
     {
         return true;
     }
 }