struct Sthx::TreeData

Overview

Tree consists of two parts: a "header" part with the tree's capture id, begin character index, and span; and a "body" part. TreeData is this body part. It is filled by callees and then wrapped in a tree by the caller after it determines the end position. A tree cannot be constructed without knowing the end position - and a tree "body", TreeData, can.

Defined in:

synthax/tree.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(children : Pf::Map(Int32, Tree) | Nil = nil, attributes : Pf::Map(String, Bytes) | Nil = nil) #

[View source]

Instance Method Detail

def append(tree : Tree) #

Returns a copy of self with tree appended as a child tree.


[View source]
def degree : Int32 #

Returns the number of children.


[View source]
def each_attribute(& : String, Bytes -> ) : Nil #

Yields each attribute: its name and a string view of its value.


[View source]
def each_child(& : Tree -> ) : Nil #

Yields each child tree.


[View source]
def empty? : Bool #

Returns true if this tree data object stores no children and no attributes.


[View source]
def getattr?(name : String) : Bytes | Nil #

Returns a string view of the value of the attribute with the given name. If there is no such attribute, returns nil.


[View source]
def getchild?(n : Int32) : Tree | Nil #

Returns the nth child tree.

Returns nil if n is out of bounds.


[View source]
def inspect(io, tree, inner, outer) #

[View source]
def setattr(name : String, value : Bytes) : TreeData #

Returns a copy of self where the attribute with the given name is assigned to value, a string view of the value of the attribute.


[View source]