Class JjtreeBuilder<N extends AbstractJjtreeNode<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 Detail

      • JjtreeBuilder

        public JjtreeBuilder()
    • 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.
        n - Node to close
        condition - Whether to close the node or not
        lastToken - Last token that was consumed while the node scope was open