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
public final class JjtreeBuilder<N extends AbstractJjtreeNode<N,?>> extends Object
Shared implementation of the tree builder generated by JJTree.
-
-
Constructor Summary
Constructors Constructor Description JjtreeBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearNodeScope(N n)
void
closeNodeScope(N n, boolean condition, JavaccToken lastToken)
Close the node scope if the condition is true.void
closeNodeScope(N n, int num, JavaccToken lastToken)
Close the node scope and adds the given number of children to the node.void
injectRight(int n)
boolean
isInjectionPending()
int
nodeArity()
Returns the number of children on the stack in the current node scope.boolean
nodeCreated()
Determines whether the current node was actually closed and pushed.void
openNodeScope(N n, JavaccToken firstToken)
N
peekNode()
Returns the node currently on the top of the stack.N
peekNode(int n)
Peek the nth node from the top of the stack.N
popNode()
Returns the node on the top of the stack, and remove it from the stack.void
pushNode(N n)
Pushes a node on to the stack.void
reset()
Call this to reinitialize the node stack.N
rootNode()
Returns the root node of the AST.
-
-
-
Method Detail
-
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
public N rootNode()
Returns the root node of the AST. It only makes sense to call this after a successful parse.
-
peekNode
public N peekNode(int n)
Peek the nth node from the top of the stack. peekNode(0) == peekNode()
-
isInjectionPending
public boolean isInjectionPending()
-
injectRight
public void injectRight(int n)
-
pushNode
public void pushNode(N n)
Pushes a node on to the stack.
-
popNode
public N popNode()
Returns the node on the top of the stack, and remove it from the stack.
-
peekNode
public N 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
public void clearNodeScope(N n)
-
openNodeScope
public void openNodeScope(N n, JavaccToken firstToken)
-
closeNodeScope
public void closeNodeScope(N n, int num, JavaccToken lastToken)
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
public void closeNodeScope(N n, boolean condition, JavaccToken lastToken)
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
-
-