class

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

to_msgpack(parse_tree : ParseTree) : Bytes

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.)>

Source

Instance methods

capture(name : String) : ParseTree
Source
capture?(name : String) : ParseTree | Nil
Source
captures(name : String) : Array(ParseTree)
Source
captures
Source
child
Source
child?
Source
children

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.

Source
descendants

returns all descendants listed out in a pre-order traversal

Source
enclosing_rule_name

returns the name of the rule that, as a result of being evaluated, yielded this parse tree node

Source
finishing_pos
Source
finishing_pos=(finishing_pos : Int32)
Source
input
Source
input=(input : CharArray)
Source
label
Source
label=(label : String | Nil)
Source
labeled?
Source
local_captures
Source
parent
Source
parent=(parent : ParseTree | Nil)
Source
parse_tree_type_specific_attributes_to_msgpack(packer : MessagePack::Packer)
Source
postorder_traverse
Source
postorder_traverse(visit : ParseTree -> _)
Source
preorder_traverse(visit : ParseTree -> _)
Source
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

Source
root
Source
root?
Source
s_exp(indent : Int32 = 0) : String
Source
self_and_descendants

returns all nodes listed out in a pre-order traversal

Source
set_label(label : Nil | String)
Source
simple_s_exp
Source
start_pos
Source
start_pos=(start_pos : Int32)
Source
syntax_tree
Source
terminal?
Source
text

returns the matched substring of the input that this parse tree node represents

Source
to_msgpack(packer : MessagePack::Packer)

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.)>

Source
visit(visitor : Visitor(R)) forall R
Source