if (reduceactions.length>0)
{
for (int i = 0; i<reduceactions.length; i++)
{
Production production = reduceactions[i].production;
ProductionNode productionnode = new ProductionNode(production);
TreeNode[] descendants = new TreeNode[production.getDefinition().getSymbolCount()];
StateNode ancestor = statenode;
for (int j = production.getDefinition().getSymbolCount()-1; j>=0; j--)
{
descendants[j] = ancestor.treenode;
ancestor = ancestor.ancestor;
}
productionnode.descendants = descendants;
ShiftAction shiftaction = ancestor.state.getShiftAction(productionnode.symbol);
//System.out.println("current state:\n"+ancestor.state+"\ntransition for "+productionnode.symbol+" = "+shiftaction);
if ((automaton.getState(0)==ancestor.state) &&
(productionnode.symbol.equals(grammar.getStartSymbol())))
{
if ((log!=null) && (log.isDebugEnabled()))
log.debug("State "+state+" accept");
StateNode newstatenode = getStateNode(next, null, ancestor);
if (newstatenode==null)
{
newstatenode = new StateNode(null, ancestor, productionnode);
next.push(newstatenode);
}
else
{
System.out.println("merging state node");
ProductionNode oldproductionnode = (ProductionNode)newstatenode.treenode;
if (grammar.getPriority(oldproductionnode.production)>grammar.getPriority(production))
{
System.out.println("priority("+production+") < priority("+
oldproductionnode.production+")");
newstatenode.treenode = productionnode;
}
else
System.out.println("priority("+production+") >= priority("+
oldproductionnode.production+")");
}
}
else
{
if ((log!=null) && (log.isDebugEnabled()))
log.debug(
/*"State "+node.state+*/
" reduce "+production.getSymbol()+" ("+production+")");
/* StateNode newstatenode = new
StateNode(ancestor.state.getShiftAction(productionnode.symbol).state, ancestor, productionnode);
current.push(newstatenode);*/