예제 #1
0
        private void runHandler(ProductionIndex productionIndex, GOLD.Reduction reduction)
        {
            ProductionHandler handler = m_Handlers[(int)productionIndex];

            if (handler != null)
            {
                handler(reduction);
            }
        }
예제 #2
0
        // Traverses recursively the parse tree and looks for grammar productions
        protected void ProcessParseTree(GOLD.Reduction topLevelNode)
        {
            ProductionIndex productionIndex = (ProductionIndex)topLevelNode.Parent.TableIndex();

            runHandler(productionIndex, topLevelNode);

            // Process child nodes recursively
            for (int i = 0; i < topLevelNode.Count(); i++)
            {
                if (topLevelNode[i].Type() == GOLD.SymbolType.Nonterminal) // Skip terminals at this level
                {
                    ProcessParseTree((GOLD.Reduction)topLevelNode[i].Data);
                }
            }
        }
예제 #3
0
 // Adds a user defined producttion handler
 protected void AddProductionHandler(ProductionIndex productionIndex, ProductionHandler productionHandler)
 {
     m_Handlers[(int)productionIndex] += productionHandler;
 }