TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

class AstNode in Tinman.Core.Parsing

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

sealed class AstNode implements ICodeRange

Public / Attributes

Children

Returns the child nodes of this AST node.

public property Children { get }
type IVectorConst<AstNode>
value [not-null] The child nodes.

Count

Returns the number of child nodes.

public property Count { get }
type int32
value [>=0] The number of child nodes.

End

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

public property End { get }
type int32
value [>=0] The token index.

First

Returns the first child node (index 0).

public property First { get }
type AstNode
value The first child node or null if it does not exist.

Grammar

The grammar that owns Rule.

public property Grammar { get }
type Grammar
value The grammar object or null.

Last

Returns the last child node.

public property Last { get }
type AstNode
value The last child node or null if it does not exist.

Range

Returns source code range of this object.

public property Range { get }
type RangeI
value The source code character range or Inv if none.
implements ICodeRange.Range

Rule

The rule that has created this AST node.

public property Rule { get }
type IRule
value [not-null] The rule.

Second

Returns the first child node (index 1).

public property Second { get }
type AstNode
value The first child node or null if it does not exist.

Start

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

public property Start { get }
type int32
value [>=0] The token index.

Third

Returns the first child node (index 2).

public property Third { get }
type AstNode
value The first child node or null if it does not exist.

Type

The input token type.

public property Type { get }
type string
value [not-null] The token type.

Public / Methods

CheckCount

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

public method CheckCount (ICodeInput input, int32 minimum = 0, int32 maximum = 0)
params input [not-null] The code input, for error reporting.
  minimum [>=0] The minimum number of child nodes. Defaults to 0.
  maximum [>=0] The maximum number of child nodes. Set to 0 to disable this check. Defaults to 0.

Exceptions:

CheckType

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

public method CheckType (ICodeInput input, string expectedType)
params input [not-null] The code input, for error reporting.
  expectedType [not-empty] The expected node type.

Exceptions:

CheckValue

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

public method CheckValue (ICodeInput input, string expectedValue)
params input [not-null] The code input, for error reporting.
  expectedValue [not-null] The expected value.

Exceptions:

Child

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

[Pure]
public method Child (string type)
type AstNode
params type [not-null] The token type.
returns The first matching child node or null.

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

[Pure]
public method Child (int32 n)
type AstNode
params n [0..Children.Count-1] Index of child node.
returns [not-null] The child node.

CreatePsi

Creates the PSI model for this AST node.

public method CreatePsi (ICodeInput input, Context context)
type object
params input [not-null] The code input object.
  context [not-null] The context object.
returns [not-null] The PSI model object.

Exceptions:

Extract

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

public method Extract (string sourceCode)
type string
params sourceCode [not-null] The source code string.
returns [not-null] The AST node range.

Remarks:

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

See also:

ICodeInput.Range

ToString

[Pure]
public override method ToString ()
type string

ToStringGrammar

Generates a textual dump of the AST node hierarchy.

public method ToStringGrammar ()
type string
returns [not-null] The textual dump string.

See also:

RuleToSourceFlags.GrammarAst

ToStringTree

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

public method ToStringTree ()
type string
returns [not-null] The string representation.

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

public method ToStringTree (string input)
type string
params input Optional parser input string for more detailed dump.
returns [not-null] The string representation.

Value

Returns the value of this AST node.

[Pure]
public method Value (ICodeInput input)
type string
params input [not-null] The code input.
returns [not-null] The node value.