struct Sthx::TreeData
- Sthx::TreeData
- Struct
- Value
- Object
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.crConstructors
Instance Method Summary
-
#append(tree : Tree)
Returns a copy of
self
with tree appended as a child tree. -
#degree : Int32
Returns the number of children.
-
#each_attribute(& : String, Bytes -> ) : Nil
Yields each attribute: its name and a string view of its value.
-
#each_child(& : Tree -> ) : Nil
Yields each child tree.
-
#empty? : Bool
Returns
true
if this tree data object stores no children and no attributes. -
#getattr?(name : String) : Bytes | Nil
Returns a string view of the value of the attribute with the given name.
-
#getchild?(n : Int32) : Tree | Nil
Returns the nth child tree.
- #inspect(io, tree, inner, outer)
-
#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.
Constructor Detail
Instance Method Detail
Yields each attribute: its name and a string view of its value.
Returns a string view of the value of the attribute with the given
name. If there is no such attribute, returns nil
.
Returns the nth child tree.
Returns nil
if n is out of bounds.
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.