Arborist::ParseTree
Inherits Reference / Object
A nil parse tree means parse error ParseTree is an abstract base class that defines one required field: finishing_pos : Int32
Constructors
Class methods
This method returns a serialized representation of the specified parse tree, encoded with MessagePack.
The serialization layout is:
<input><array of ParseTree nodes>
Each ParseTree node is represented with the following structure:
<node type (ApplyTree | TerminalTree | ...)>
<node ID>
<input start position (inclusive)>
<input end position (inclusive)>
<node label (may be nil)>
<parent node ID (may be nil)>
<array of children node IDs>
<array of captures, where each capture is a 4-tuple (String,Int32,Int32,Int32),
representing (capture name, node ID belonging to referenced node, input start position inclusive, input end position inclusive) >
<node attributes specific to the type of node (e.g. ApplyTree has a rule_name attribute; TerminalTree has a str attribute; etc.)>
Instance methods
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 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
Each ParseTree node is represented with the following structure: <node type (ApplyTree | TerminalTree | ...)> <node ID> <input start position (inclusive)> <input end position (inclusive)> <node label (may be nil)> <parent node ID (may be nil)> <array of children node IDs> <map of captures, having type Map(String, Array(UInt64)), representing: <capture name> => [node ID belonging to referenced node, another node ID belonging to referenced node, ...], <capture name> => [node ID belonging to referenced node, another node ID belonging to referenced node, ...], ...
<node attributes specific to the type of node (e.g. ApplyTree has a rule_name attribute; TerminalTree has a str attribute; etc.)>