Class JjtreeBuilder<N extends AbstractJjtreeNode<N,?>>
java.lang.Object
net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeBuilder<N>
- Type Parameters:
N- Internal base class for nodes
Shared implementation of the tree builder generated by JJTree.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearNodeScope(N n) voidcloseNodeScope(N n, boolean condition, JavaccToken lastToken) Close the node scope if the condition is true.voidcloseNodeScope(N n, int num, JavaccToken lastToken) Close the node scope and adds the given number of children to the node.voidinjectRight(int n) booleanintReturns the number of children on the stack in the current node scope.booleanDetermines whether the current node was actually closed and pushed.voidopenNodeScope(N n, JavaccToken firstToken) peekNode()Returns the node currently on the top of the stack.peekNode(int n) Peek the nth node from the top of the stack.popNode()Returns the node on the top of the stack, and remove it from the stack.voidPushes a node on to the stack.voidreset()Call this to reinitialize the node stack.rootNode()Returns the root node of the AST.
-
Constructor Details
-
JjtreeBuilder
public JjtreeBuilder()
-
-
Method Details
-
nodeCreated
public boolean nodeCreated()Determines whether the current node was actually closed and pushed. This should only be called in the final user action of a node scope. -
reset
public void reset()Call this to reinitialize the node stack. It is called automatically by the parser's ReInit() method. -
rootNode
Returns the root node of the AST. It only makes sense to call this after a successful parse. -
peekNode
Peek the nth node from the top of the stack. peekNode(0) == peekNode() -
isInjectionPending
public boolean isInjectionPending() -
injectRight
public void injectRight(int n) -
pushNode
Pushes a node on to the stack. -
popNode
Returns the node on the top of the stack, and remove it from the stack. -
peekNode
Returns the node currently on the top of the stack. -
nodeArity
public int nodeArity()Returns the number of children on the stack in the current node scope. -
clearNodeScope
-
openNodeScope
-
closeNodeScope
Close the node scope and adds the given number of children to the node. A definite node is constructed from a specified number of children. That number of nodes are popped from the stack and made the children of the definite node. Then the definite node is pushed on to the stack. -
closeNodeScope
Close the node scope if the condition is true. All the nodes that have been pushed since the node was opened are made children of the conditional node, which is then pushed on to the stack. If the condition is false the node is not constructed and they are left on the stack.- Parameters:
n- Node to closecondition- Whether to close the node or notlastToken- Last token that was consumed while the node scope was open
-