Errai 3.0.1-SNAPSHOT

org.jboss.errai.jpa.rebind
Class AstInorderTraversal

java.lang.Object
  extended by org.jboss.errai.jpa.rebind.AstInorderTraversal
All Implemented Interfaces:
Iterator<antlr.collections.AST>

public class AstInorderTraversal
extends Object
implements Iterator<antlr.collections.AST>

Facilitates iteration through the nodes of an ANTLR AST. The iteration order is an in-order traversal of the nodes in the tree.

Author:
Jonathan Fuerth

Constructor Summary
AstInorderTraversal(antlr.collections.AST ast)
          Creates a new traversal of the given AST.
 
Method Summary
 Deque<antlr.collections.AST> context()
          Returns the stack of AST nodes that lead from the root of the AST down to the current node that this traverser is positioned on.
 antlr.collections.AST fastForwardTo(antlr.collections.AST node)
           
 antlr.collections.AST fastForwardTo(int nodeType)
           
 void fastForwardToNextSiblingOf(antlr.collections.AST node)
          Advances this iterator past the subtree rooted at the given node.
 boolean hasNext()
           
 antlr.collections.AST next()
           
 void remove()
          Not implemented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AstInorderTraversal

public AstInorderTraversal(antlr.collections.AST ast)
Creates a new traversal of the given AST. Multiple traversers can exist independently on the same AST.

Parameters:
ast - The AST to traverse. Must not be null.
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<antlr.collections.AST>

next

public antlr.collections.AST next()
Specified by:
next in interface Iterator<antlr.collections.AST>

context

public Deque<antlr.collections.AST> context()
Returns the stack of AST nodes that lead from the root of the AST down to the current node that this traverser is positioned on.

Returns:
A sequence of nodes, where the first item in the list is the root of the AST, the last item is the current node, and all elements have the relationship that the node at position p is the parent of the node at position p + 1.

fastForwardToNextSiblingOf

public void fastForwardToNextSiblingOf(antlr.collections.AST node)
Advances this iterator past the subtree rooted at the given node. The cursor will be left in one of the following places, depending on the position of the node:
  1. On the sibling node immediately following the given node, if such a node exists
  2. On an "uncle": the next sibling of the first ancestor node that has an unvisited sibling, if such a node exists
  3. At the end of the iteration (hasNext() will return false).

Parameters:
node - The node to fast-forward past.

fastForwardTo

public antlr.collections.AST fastForwardTo(int nodeType)

fastForwardTo

public antlr.collections.AST fastForwardTo(antlr.collections.AST node)

remove

public void remove()
Not implemented.

Specified by:
remove in interface Iterator<antlr.collections.AST>
Throws:
UnsupportedOperationException - when called

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.