Beispiel #1
0
        public bool ParseProgramm(out SyntaxTree syntaxTree)
        {
            syntaxTree = null;

            SyntaxTreeNode rootNode = IsProgramm();
            syntaxTree = new SyntaxTree(rootNode);

            return rootNode != null;
        }
 internal bool RunDelegateForType(System.Type type, SyntaxTree.TreeNodeDelegate delegateToRun)
 {
     bool result = true;
     if (type.IsInstanceOfType(this))
     {
         result = delegateToRun(this);
     }
     foreach (var node in this._children)
     {
         if (node != null)
             result &= node.RunDelegateForType(type, delegateToRun);
     }
     return result;
 }
Beispiel #3
0
        static bool RunPhase_3(FileManager fileManager, SyntaxTree syntaxTree, SymbolTable symbolTable, CodeGeneratorHelper cdh)
        {
            fileManager.InitializeOutputFile();
            syntaxTree.GenerateCode(fileManager, symbolTable, cdh);
            fileManager.FinalizeOutputFile();

            return true;
        }
Beispiel #4
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;
            }
        }
Beispiel #5
0
 static bool RunPhase_2(SyntaxTree syntaxTree, SymbolTable symbolTable, CodeGeneratorHelper storage)
 {
     if (syntaxTree.CheckForSemanticErrors(symbolTable) &&
         syntaxTree.AllocateMemoryForConstants(storage) &&
         syntaxTree.AllocateMemoryForVariables(storage))
     {
         return true;
     }
     return false;
 }