Click or drag to resize

ITree Interface

What does a tree look like? ANTLR has a number of support classes such as CommonTreeNodeStream that work on these kinds of trees. You don't have to make your trees implement this interface, but if you do, you'll be able to use more support code.

Namespace:  Stimulsoft.Data.Expressions.Antlr.Runtime.Tree
Assembly:  Stimulsoft.Data (in Stimulsoft.Data.dll) Version: 2019.3.1.0
Syntax
public interface ITree

The ITree type exposes the following members.

Properties
  NameDescription
Public propertyCharPositionInLine
Public propertyChildCount
Public propertyChildIndex
This node is what child index? 0..n-1
Public propertyIsNil
Indicates the node is a nil node but may still have children, meaning the tree is a flat list.
Public propertyLine
In case we don't have a token payload, what is the line for errors?
Public propertyParent
Public propertyText
Public propertyTokenStartIndex
What is the smallest token index (indexing from 0) for this node and its children?
Public propertyTokenStopIndex
What is the largest token index (indexing from 0) for this node and its children?
Public propertyType
Return a token type; needed for tree parsing
Top
Methods
  NameDescription
Public methodAddChild
Add t as a child to this node. If t is null, do nothing. If t is nil, add all children of t to this' children.
Public methodDeleteChild
Public methodDupNode
Public methodFreshenParentAndChildIndexes
Set the parent and child index values for all children
Public methodGetAncestor
Walk upwards and get first ancestor with this token type.
Public methodGetAncestors
Return a list of all ancestors of this node. The first node of list is the root and the last is the parent of this node.
Public methodGetChild
Public methodHasAncestor
Is there is a node above with token type ttype?
Public methodReplaceChildren
Delete children from start to stop and replace with t even if t is a list (nil-root tree). num of children can increase or decrease. For huge child lists, inserting children can force walking rest of children to set their childindex; could be slow.
Public methodSetChild
Set ith child (0..n-1) to t; t must be non-null and non-nil node
Public methodToString
Public methodToStringTree
Top
Remarks
NOTE: When constructing trees, ANTLR can build any kind of tree; it can even use Token objects as trees if you add a child list to your tokens. This is a tree node without any payload; just navigation and factory stuff.
See Also