module ANTLR3::AST::TreeNodeStream

TreeNodeStreams flatten two-dimensional tree structures into one-dimensional sequences. They preserve the two-dimensional structure of the tree by inserting special UP and DOWN nodes.

Consider a hypothetical tree:

[A]
 +--[B]
 |   +--[C]
 |   `--[D]
 `--[E]
     `--[F]

A tree node stream would serialize the tree into the following sequence:

A DOWN B DOWN C D UP E DOWN F UP UP EOF

Other than serializing a tree into a sequence of nodes, a tree node stream operates similarly to other streams. They are commonly used by tree parsers as the main form of input. peek, like token streams, returns the type of the token of the next node. look returns the next full tree node.