Class ASTNode<T>

Type Parameters

  • T

Hierarchy

  • ASTNode

Constructors

  • Type Parameters

    • T

    Parameters

    • p: Partial<Pick<ASTNode<T>, "error" | "text" | "children" | "parent" | "data" | "$">> & Pick<ASTNode<T>, "type" | "start"> & {
          traverser?: Traverser<T>;
      }

    Returns ASTNode<T>

Properties

Find AST node by its type name or literal value.

children?: readonly ASTNode<T>[]

NT's children.

data?: T
error?: any
parent?: ASTNode<T>

Parent must be an NT unless this node is the root node, in this case parent is null.

start: number

Start position of the input string. Same as the first token's start position.

str?: string

Cache the string representation.

text?: string

T's text content.

traverser?: Traverser<T>

traverser shouldn't be exposed because we want users to use traverse instead of traverser directly.

type: string

T's or NT's name.

Methods

  • Return type name. If the type is anonymous, return "literal value".

    Returns string

  • Return a tree-structured string.

    Parameters

    • Optional options: {
          anonymous?: string;
          indent?: string;
          initialIndent?: string;
      }
      • Optional anonymous?: string
      • Optional indent?: string
      • Optional initialIndent?: string

    Returns string

  • Try to use the traverser to calculate data and return the data.

    Returns undefined | T

Generated using TypeDoc