コード例 #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();
        }