class Arborist::ParseTree
- Arborist::ParseTree
- Reference
- Object
Overview
A nil parse tree means parse error ParseTree is an abstract base class that defines one required field: finishing_pos : Int32
Direct Known Subclasses
- Arborist::ApplyTree
- Arborist::ChoiceTree
- Arborist::MutexAltTree
- Arborist::NegLookAheadTree
- Arborist::OptionalTree
- Arborist::PosLookAheadTree
- Arborist::RepetitionTree
- Arborist::SequenceTree
- Arborist::TerminalTree
Defined in:
parse_tree.crConstructors
Class Method Summary
-
.to_msgpack(parse_tree : ParseTree) : Bytes
This method returns a serialized representation of the specified parse tree, encoded with MessagePack.
Instance Method Summary
- #capture(name : String) : ParseTree
- #capture?(name : String) : ParseTree | Nil
- #captures(name : String) : Array(ParseTree)
- #captures : Hash(String, Array(ParseTree))
- #child : ParseTree
- #child? : ParseTree | Nil
-
#children : Array(ParseTree)
children returns the list of all actual/literal child ParseTree nodes in parse tree structure, rather than skipping some, as with #terms Another way of thinking about this is #children returns concrete children, #terms returns logical children.
-
#descendants : Array(ParseTree)
returns all descendants listed out in a pre-order traversal
-
#enclosing_rule_name : String | Nil
returns the name of the rule that, as a result of being evaluated, yielded this parse tree node
- #finishing_pos : Int32
- #finishing_pos=(finishing_pos : Int32)
- #input : CharArray
- #input=(input : CharArray)
- #label : String | Nil
- #label=(label : String | Nil)
- #labeled?
- #local_captures : Hash(String, Array(ParseTree))
- #parent : ParseTree | Nil
- #parent=(parent : ParseTree | Nil)
- #parse_tree_type_specific_attributes_to_msgpack(packer : MessagePack::Packer)
- #postorder_traverse(&visit : ParseTree -> _)
- #postorder_traverse(visit : ParseTree -> _)
- #preorder_traverse(visit : ParseTree -> _)
-
#recursively_populate_parents(parent : ParseTree | Nil = nil)
call this on the root node in the tree to update all the nodes in the tree with their parent node
- #root
- #root?
- #s_exp(indent : Int32 = 0) : String
-
#self_and_descendants : Array(ParseTree)
returns all nodes listed out in a pre-order traversal
- #set_label(label : Nil | String)
- #simple_s_exp : String
- #start_pos : Int32
- #start_pos=(start_pos : Int32)
- #syntax_tree : SyntaxTree
- #terminal?
-
#text : String
returns the matched substring of the input that this parse tree node represents
-
#to_msgpack(packer : MessagePack::Packer)
Each ParseTree node is represented with the following structure: <node type (ApplyTree | TerminalTree | ...)>
<input start position (inclusive)> <input end position (inclusive)> <node label (may be nil)> <parent node ID (may be nil)> <map of captures, having type Map(String, Array(UInt64)), representing: => [node ID belonging to referenced node, another node ID belonging to referenced node, ...], => [node ID belonging to referenced node, another node ID belonging to referenced node, ...], ... - #visit(visitor : Visitor(R)) forall R
Constructor Detail
Class Method Detail
This method returns a serialized representation of the specified parse tree, encoded with MessagePack.
The serialization layout is:
rule_name
attribute; TerminalTree has a str
attribute; etc.)>
Instance Method Detail
children returns the list of all actual/literal child ParseTree nodes in parse tree structure, rather than skipping some, as with #terms Another way of thinking about this is #children returns concrete children, #terms returns logical children.
returns all descendants listed out in a pre-order traversal
returns the name of the rule that, as a result of being evaluated, yielded this parse tree node
call this on the root node in the tree to update all the nodes in the tree with their parent node
returns all nodes listed out in a pre-order traversal
Each ParseTree node is represented with the following structure:
<node type (ApplyTree | TerminalTree | ...)>
<node attributes specific to the type of node (e.g. ApplyTree has a rule_name
attribute; TerminalTree has a str
attribute; etc.)>