DefaultAstNode Class
Represents an AST (abstract syntax tree) node implementation that has a string value and optional child nodes.
public class DefaultAstNode : IAstNode
- Inheritance:
- object object
- Implements:
- IAstNode
Constructors
DefaultAstNode()
Initializes an instance of the class.
public DefaultAstNode()
Properties
Children
The list containing the child AST nodes.
EndOffset
The end offset of this AST node, if known.
HasChildren
Indicates whether the AST node contains any child AST nodes.
public bool HasChildren { get; }
Property Value
- bool:
trueif the AST node contains any child AST nodes; otherwise,false.
Id
An integer value that identifies the type of AST node, if known.
public virtual int Id { get; }
Property Value
Remarks
This class' default implementation always returns 0.
Length
The character length of this AST node, if known.
Parent
The parent IAstNode of this AST node, if known.
StartOffset
The start offset of this AST node, if known.
Value
The string-based value for the AST node.
Methods
Contains(int)
Returns whether the AST node contains the specified offset.
public bool Contains(int offset)
| Parameter | Type | Description |
|---|---|---|
| offset | int | The offset to examine. |
Returns
- bool:
trueif the AST node contains the specified offset; otherwise,false.
Remarks
This method returns false if the offset falls on the EndOffset offset
since this method indicates if the offset is encompassed by the AST node.
This method also returns false if the AST node doesn't have known offsets.
FindChildNode(int)
Searches through the child nodes for a node that contains the specified offset.
public IAstNode? FindChildNode(int offset)
| Parameter | Type | Description |
|---|---|---|
| offset | int | The offset to check. |
Returns
FindDescendantNode(int)
Recursively searches through the descendant nodes for a node that contains the specified offset.
public IAstNode? FindDescendantNode(int offset)
| Parameter | Type | Description |
|---|---|---|
| offset | int | The offset to check. |
Returns
ToString()
Returns the string representation of this object.
ToTreeString(int)
Outputs the contents of the AST node in tree form.
public string ToTreeString(int indentLevel)
| Parameter | Type | Description |
|---|---|---|
| indentLevel | int | The indentation level. |
Returns
Inherited Members
- object.GetType()
- object.MemberwiseClone()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()