A node in the parse tree, passed to Action functions.

interface Node {
    children: Node[];
    ctorName: string;
    numChildren: number;
    source: Interval;
    sourceString: string;
    asIteration(): IterationNode;
    child(idx): Node;
    isIteration(): boolean;
    isOptional(): boolean;
    isTerminal(): boolean;
    [index: string]: any;
}

Hierarchy (view full)

Indexable

[index: string]: any

In addition to the properties defined above, within a given semantics, every node also has a method/property corresponding to each operation/attribute in the semantics. For example, in a semantics that has an operation named 'prettyPrint' and an attribute named 'freeVars', every node has a prettyPrint() method and a freeVars property. NOTE this means the above node properties can not be used as operation/attribute names.

Properties

children: Node[]

An array containing the node's children.

ctorName: string

The name of grammar rule that created the node.

numChildren: number

The number of child nodes that the node has.

source: Interval

Captures the portion of the input that was consumed by the node.

sourceString: string

Returns the contents of the input stream consumed by this node.

Methods

  • A built-in operation which can convert certain NonterminalNodes into IterationNodes. This operation is defined for the built-in list rules (ListOf, EmptyListOf, NonemptyListOf, listOf, ...), and can also be defined for user-defined rules.

    Returns IterationNode

  • Returns the child at index idx.

    Parameters

    • idx: number

    Returns Node

  • true if the node is an iteration node, which corresponds to a +, *, or ? expression in the grammar.

    Returns boolean

  • True if Node is ? option

    Returns boolean

  • true if the node is a terminal node, otherwise false.

    Returns boolean

Generated using TypeDoc