Class ParseTreeTraverser


  • public abstract class ParseTreeTraverser
    extends java.lang.Object
    This traverser class encapsulates two methods of traversing a tree, calling a Visitor for each subtree of a ParseTree<Node>.

    Each subtree can be visited in ‘pre-order’ as well asO in ‘post-order’. ‘Pre-order’ visits each subtree before any of its child subtrees, and ‘post-order’ visits each subtree after visiting its child subtrees.

    traverse(ParseTree, Visitor) visits each subtree twice: combining ‘pre-order’ and ‘post-order’ traversal in one pass.

    The Visitor contract returns a boolean flag from its visit methods which these traversal algorithms interpret as immediate abort: no further visits will be made after the first returns false. Each traversal method returns true if all the tree is visited, and false if any visit aborted.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <Node> boolean traverse​(ParseTree<Node> tree, Visitor<Node> visitor)
      Visits each subtree in both ‘pre-order’ and ‘post-order’, in one pass.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait