Module: ANTLR3::AST::TreeNodeStream

Extended by:
ClassMacros
Includes:
Constants, Stream
Included in:
CommonTreeNodeStream
Defined in:
lib/antlr3/tree.rb

Overview

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.

Constant Summary

Constants included from Constants

Constants::BUILT_IN_TOKEN_NAMES, Constants::DEFAULT, Constants::DOWN, Constants::EOF, Constants::EOF_TOKEN, Constants::EOR_TOKEN_TYPE, Constants::HIDDEN, Constants::INVALID, Constants::INVALID_TOKEN, Constants::MEMO_RULE_FAILED, Constants::MEMO_RULE_UNKNOWN, Constants::MIN_TOKEN_TYPE, Constants::SKIP_TOKEN, Constants::UP

Instance Attribute Summary

Attributes included from Stream

#size, #source_name

Method Summary

Methods included from Stream

#consume, #index, #look, #mark, #peek, #release, #rewind, #seek