public GeneratedScannerWrapper(FileManager fileManager, SymbolTable symbolTable)
 {
     this._scanner = new NaseScanner(fileManager.Input);
     this._scanner.SymbolTable = symbolTable;
     this._symbolTable = symbolTable;
     this._peekSymbol = (Symbol)this._scanner.yylex();
     if (this._peekSymbol == Symbol.INTEGER_LITERAL_SYMBOL || this._peekSymbol == Symbol.IDENTIFIER_SYMBOL)
     {
         UpdateSymbol();
     }
 }
Esempio n. 2
0
        static bool RunPhase_1(FileManager fileManager, SymbolTable symbolTable, out SyntaxTree syntaxTree)
        {
            if (false)
            {
                IScanner scanner = new GeneratedScannerWrapper(fileManager, symbolTable);
                //IScanner scanner = new Scanner(fileManager, symbolTable);
                Parser parser = new Parser(symbolTable, scanner);

                bool result = parser.ParseProgramm(out syntaxTree);

                Logger.Debug(symbolTable.DumpSymbolTable());
                Logger.Debug(syntaxTree.DumpTreeTable());

                return result;
            }
            else
            {
                NaseScanner scanner = new NaseScanner(fileManager.Input);
                scanner.SymbolTable = symbolTable;
                NaseParser parser = new NaseParser(scanner, symbolTable);
                bool result = parser.Parse();

                syntaxTree = parser.SyntaxTree;

                if (result)
                {
                    Logger.Debug(symbolTable.DumpSymbolTable());
                    Logger.Debug(syntaxTree.DumpTreeTable());
                }

                return result;
            }
        }