Пример #1
0
        // Initializes and runs Code Generator module
        public static void StartCodeGenerator(string[] arguments)
        {
            CommonTools.ThreeAddressCodeRun = true;
            ValidateArguments(arguments);
            CommonTools.SetupOutputs(new string[] { GlobalConfiguration.ThreeAddressCodeOutputPath,
                                                    AppendFileExtension(arguments[0], "tac") });
            CommonTools.ClearOutputDisplays();

            LexicalAnalyzer lexicalAnalyzer = new LexicalAnalyzer(arguments[0]);

            lexicalAnalyzer.GetNextToken();

            SymbolTable symbolTable = new SymbolTable();
            Parser      parser      = new Parser(lexicalAnalyzer, symbolTable);

            if (parser.Start())
            {
                CommonTools.SetupOutputs
                    (new string[] { GlobalConfiguration.CodeGeneratorOutputPath,
                                    AppendFileExtension(arguments[0], "asm") });
                CommonTools.ClearOutputDisplays();
                CodeGenerator codeGenerator = new CodeGenerator(AppendFileExtension(arguments[0], "tac"), symbolTable);
                codeGenerator.Start();
            }

            CommonTools.PromptProgramExit();
        }
Пример #2
0
        // Initializes and runs Lexical Analysis module
        public static void StartLexicalAnalyzer(string[] arguments)
        {
            ValidateArguments(arguments);
            CommonTools.SetupOutputs(new string[] { GlobalConfiguration.LexicalAnalyzerOutputPath });
            CommonTools.ClearOutputDisplays();

            LexicalAnalyzer lexicalAnalyzer = new LexicalAnalyzer(arguments[0]);

            CommonTools.DisplayHeader = lexicalAnalyzer.DisplayTokenHeader;
            lexicalAnalyzer.DisplayTokenHeader();

            while (lexicalAnalyzer.Token != Token.EndOfFileToken)
            {
                lexicalAnalyzer.GetNextToken();
                lexicalAnalyzer.DisplayCurrentToken();
            }
            CommonTools.PromptProgramExit();
        }
Пример #3
0
        // Initializes and runs Parser module
        public static void StartParser(string[] arguments)
        {
            ValidateArguments(arguments);
            CommonTools.SetupOutputs(new string[] { GlobalConfiguration.ParserOutputPath });
            CommonTools.ClearOutputDisplays();

            LexicalAnalyzer lexicalAnalyzer = new LexicalAnalyzer(arguments[0]);

            lexicalAnalyzer.GetNextToken();

            SymbolTable symbolTable = new SymbolTable();
            Parser      parser      = new Parser(lexicalAnalyzer, symbolTable);

            if (parser.Start())
            {
                symbolTable.OutputSymbolTable(1);
            }

            CommonTools.WriteOutput($"Completed processing {Path.GetFileName(arguments[0])}");
            CommonTools.PromptProgramExit();
        }
Пример #4
0
 // Initializes and runs Symbol Table module
 public static void StartSymbolTable()
 {
     CommonTools.SetupOutputs(new string[] { GlobalConfiguration.SymbolTableOutputPath });
     CommonTools.ClearOutputDisplays();
     CommonTools.PromptProgramExit();
 }