coins.ast
Class TreeWalker

java.lang.Object
  extended bycoins.ast.TreeWalker

public class TreeWalker
extends java.lang.Object

A helper class for traversing a tree.


Nested Class Summary
(package private) static class TreeWalker.NodeList
           
 
Constructor Summary
TreeWalker(ASTree root)
           
 
Method Summary
 ASTree begin()
          Moves to the leftmost leaf node.
 TreeWalker copy()
          Makes a copy of the TreeWalker object.
 ASTree current()
          Returns the object at the current position.
 ASTree left()
          Move to the left child.
 ASTree next()
          Move to the next node in the post-order traversal.
 ASTree parent()
          Move to the parent.
 ASTree right()
          Move to the right child.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeWalker

public TreeWalker(ASTree root)
Method Detail

copy

public TreeWalker copy()
Makes a copy of the TreeWalker object. The current position is also copied.


begin

public ASTree begin()
Moves to the leftmost leaf node. This method must be called before next() is called.


next

public ASTree next()
Move to the next node in the post-order traversal. This method skips a Pair node.


current

public ASTree current()
Returns the object at the current position. This method returns null if parent() is called when the current position is a root node.


left

public ASTree left()
Move to the left child. This method returns null if the current position is a leaf node.


right

public ASTree right()
Move to the right child. This method returns null if the current position is a leaf node.


parent

public ASTree parent()
Move to the parent. This method returns null if the current position is a root node.