private void runHandler(ProductionIndex productionIndex, GOLD.Reduction reduction) { ProductionHandler handler = m_Handlers[(int)productionIndex]; if (handler != null) { handler(reduction); } }
// 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); } } }
// Adds a user defined producttion handler protected void AddProductionHandler(ProductionIndex productionIndex, ProductionHandler productionHandler) { m_Handlers[(int)productionIndex] += productionHandler; }