class Rley::PTree::ParseTree
A parse tree (a.k.a. concrete syntax tree) is a tree-based representation for the parse that corresponds to the input text. In a parse tree, a node corresponds to a grammar symbol used during the parsing:
-
a leaf node maps to a terminal symbol occurring in
the input, and
-
a intermediate node maps to a non-terminal node reduced
during the parse. The root node corresponds to the main/start symbol of the grammar.
Attributes
@return [ParseTreeNode] The root node of the tree.
Public Class Methods
Source
# File lib/rley/ptree/parse_tree.rb, line 21 def initialize(theRootNode) @root = theRootNode end
@param theRootNode [ParseTreeNode] The root node of the parse tree.
Public Instance Methods
Source
# File lib/rley/ptree/parse_tree.rb, line 34 def accept(aVisitor) aVisitor.start_visit_ptree(self) # Let's proceed with the visit of nodes root&.accept(aVisitor) aVisitor.end_visit_ptree(self) end
Part of the ‘visitee’ role in the Visitor design pattern.
A visitee is expected to accept the visit from a visitor object
@param aVisitor [ParseTreeVisitor] the visitor object
Source
# File lib/rley/ptree/parse_tree.rb, line 27 def done! @root.done! end
Notification from the builder telling that the parse tree construction is over. This method can be overriden.