예제 #1
0
        static void TestLexicalAnalyzer()
        {
            var errorDigest = ReadErrorDigest();
            var errorTable  = new ErrorTable(errorDigest);

            var ioModule        = new IOModule(errorTable, @"..\..\data\test_lex_3.pas", @"..\..\data\listing.txt");
            var lexicalAnalyzer = new LexicalAnalyzer(ioModule);

            Symbol.SymbolEnum symbol;
            Error             error;

            do
            {
                lexicalAnalyzer.NextSymbol();

                if (lexicalAnalyzer.Error != null)
                {
                    error = lexicalAnalyzer.Error;
                    Console.WriteLine(error.Message);
                }
                else
                {
                    symbol = lexicalAnalyzer.CurrentSymbol;
                    Console.WriteLine(symbol.ToString());
                }
            }while (!lexicalAnalyzer.IsFinished);
            ioModule.Dispose();
        }
예제 #2
0
        static void TestSyntacticAnalyzer()
        {
            var errorDigest = ReadErrorDigest();
            var errorTable  = new ErrorTable(errorDigest);

            var ioModule          = new IOModule(errorTable, @"..\..\data\test_sem_1.pas", @"..\..\data\listing.txt");
            var lexicalAnalyzer   = new LexicalAnalyzer(ioModule);
            var syntacticAnalyzer = new SyntacticAnalyzer(ioModule, lexicalAnalyzer);

            syntacticAnalyzer.Run();
            ioModule.Dispose();
        }