/** * Executes the semantic actions which can be identified by: * * <ul> * <li>the number of the currently executed rule * <li>the rule defined in an EDL grammar which was lastly applied before the currently applied * rule * <li>the current position in the rule (<code>position</code>) * </ul> * * If an {@link Exception} occurs during the execution of the semantic actions and the debug mode * is activated then the internal parse forest is printed and the application of rule which caused * the {@link Exception} is highlighted. * * @param root {@link AbstractParseNode} which is the root of the internal parse forest * @param currentNode {@link AbstractParseNode} the currently traversed node */ private void executeSemanticAction(AbstractParseNode root, AbstractParseNode currentNode) { try { StackElement currentElement = stack.getCurrentElement(); if (currentElement.getAppliedRule() != null && currentElement.getAppliedRule().canHaveSemanticAciton()) { // if the current element recognizes an input character no // semantic actions can be defined for that node graphBuilder.execute(stack); } } catch (Throwable e) { if (graphBuilder.isDebugMode()) { System.err.println("\tAn error occured: " + e.toString()); System.err.println(printParseForest(root, currentNode)); } if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new RuntimeException(e); } } }