Exemplo n.º 1
0
        public void Counter()
        {
            string       filePath    = Path.Combine(Directory.GetCurrentDirectory(), "samples/closure.st");
            Lexer        lexer       = new Lexer(new FileStream(filePath, FileMode.Open, FileAccess.Read));
            BasicParser  basicParser = new BasicParser();
            IEnvironment environment = new Interpreter.Environment();

            while (lexer.Peek(0) != Token.EOF)
            {
                ASTNode astNode = basicParser.Parse(lexer);

                if (!(astNode is NullStatement))
                {
                    astNode.Lookup(environment.SymbolTable);

                    object result = astNode.Eval(environment);

                    Console.WriteLine(result);
                }
            }
        }