AstNode

Description

sealed class Tinman.Core.Parsing.AstNode

Derived from

ICodeRange

Represents a node of an abstract syntax tree (AST).

Public / Methods

Check​Count


public method CheckCount → (3)

input in : ICodeInput

[not-null]
The code input, for error reporting.

minimum opt : int32 = 0

[>=0]
The minimum number of child nodes.

maximum opt : int32 = 0

[>=0]
The maximum number of child nodes. Set to 0 to disable this check. Defaults to 0.

Checks if the number of child nodes (see Count) is within the given range.

ValidatingException

If the check has failed.

Check​Type


public method CheckType → (2)

input in : ICodeInput

[not-null]
The code input, for error reporting.

expectedType in : string

[not-empty]
The expected node type.

Checks if the type of this node if equal to the given one.

ValidatingException

If the check has failed.

Check​Value


public method CheckValue → (2)

input in : ICodeInput

[not-null]
The code input, for error reporting.

expectedValue in : string

[not-null]
The expected value.

Checks if the textual value of this node in the code input matches the given expected value.

ValidatingException

If the check has failed.

Child

2 overloads


[Pure]
public method Child1 → (1)

type in : string

[not-null]
The token type.

returns → AstNode

The first matching child node or null.

Returns the first child node that has the given token type.


[Pure]
public method Child2 → (1)

in : int32

[0..AstNode.Children.Count-1]
Index of child node.

returns → AstNode

The child node.

Returns the n-th child node, assuming that it exists.

Create​Psi


public method CreatePsi → (2)

input in : ICodeInput

[not-null]
The code input object.

context in : Context

[not-null]
The context object.

returns → object

The PSI model object.

Creates the PSI model for this AST node.

The outermost invocation of this method will call the IPsiNode.Resolve method once on the root PSI node, before returning it.

ValidatingException

If there is no PSI factory method available for this AST node type or the AST structure is invalid.

Extract


public method Extract → (1)

sourceCode in : string

[not-null]
The source code string.

returns → string

The AST node range.

Extracts the range of this AST node from the given string.

The given string must be identical to the parser input (e.g. see CodeInput).

See also

ICodeInput.Range

To​String​Grammar


public method ToStringGrammar → ()

returns → string

The textual dump string.

Generates a textual dump of the AST node hierarchy.

To​String​Tree

2 overloads


public method ToStringTree1 → ()

returns → string

The string representation.

Returns a human-readable string representation of the AST node tree.


public method ToStringTree2 → (1)

input in : string

Optional parser input string for more detailed dump.

returns → string

The string representation.

Returns a human-readable string representation of the AST node tree.

Value


[Pure]
public method Value → (1)

input in : ICodeInput

[not-null]
The code input.

returns → string

The node value.

Returns the value of this AST node.

Public / Attributes

Children


public attribute Children → (get)

value : IVectorConst<AstNode>

[not-null]
The child nodes.

Returns the child nodes of this AST node.

Count


public attribute Count → (get)

value : int32

[>=0]
The number of child nodes.

Returns the number of child nodes.

End


public attribute End → (get)

value : int32

[>=0]
The token index.

Index of last input token that belongs to this AST node (exclusive).

First


public attribute First → (get)

value : AstNode

The first child node or null if it does not exist.

Returns the first child node (index 0).

Grammar


public attribute Grammar → (get)

value : Grammar

The grammar object or null.

The grammar that owns Rule.

Last


public attribute Last → (get)

value : AstNode

The last child node or null if it does not exist.

Returns the last child node.

Rule


public attribute Rule → (get)

value : IRule

[not-null]
The rule.

The rule that has created this AST node.

Second


public attribute Second → (get)

value : AstNode

The first child node or null if it does not exist.

Returns the first child node (index 1).

Start


public attribute Start → (get)

value : int32

[>=0]
The token index.

Index of first input token that belongs to this AST node (inclusive).

Third


public attribute Third → (get)

value : AstNode

The first child node or null if it does not exist.

Returns the first child node (index 2).

Type


public attribute Type → (get)

value : string

[not-null]
The token type.

The input token type.