The Abstract Syntax Tree will be constituted by instances of Node.

It implements Origin as it could be the source of a AST-to-AST transformation, so the node itself can be the Origin of another node.

Hierarchy (view full)

Constructors

Properties

_nodeDefinition: NodeDefinition
classifier: Classifier
destination?: Destination
lwnode: Node
origin?: Origin
parent: LionwebNode
parseTree?: ParseTree
positionOverride?: Position

Accessors

  • get sourceText(): undefined | string
  • Returns undefined | string

Methods

  • Tests whether the given position is contained in the interval represented by this object.

    Parameters

    • Optional position: Position

      the position

    Returns boolean

  • Finds the first node that satisfies a condition among this node's descendants.

    Parameters

    • predicate: ((n, index) => boolean)

      the function expressing the condition that the node must satisfy.

        • (n, index): boolean
        • Parameters

          • n: Node
          • index: number

          Returns boolean

    • Optional walker: ((node) => Generator<Node>)

      the function that generates the nodes to operate on in the desired sequence. By default, this is a depth-first traversal that includes the node on which find() has been called.

        • (node): Generator<Node>
        • A generator that walks the whole AST starting from the provided node, depth-first.

          Parameters

          • node: Node

            the starting node.

          Returns Generator<Node>

    Returns undefined | Node

    the first node in the AST for which the predicate is true. Returns undefined if none are found.

  • Note that the type is not strictly forced to be a subclass of Node. This is intended to support interfaces like Statement or Expression. However, being an ancestor the returned value is guaranteed to be a Node, as only Node instances can be part of the hierarchy.

    Parameters

    • type: any

    Returns undefined | Node

    ancestor the nearest ancestor of this node that is of type type.

  • Parameters

    • position: Position

      the position where to search for nodes

    • Optional selfContained: boolean

      whether the starting node position contains the positions of all its children. If true no further search will be performed in subtrees where the root node falls outside the given position. If false (default) the research will cover all nodes from the starting node to the leaves.

    Returns undefined | Node

    the node most closely containing the given [position]. undefined if none is found.

    See

    searchByPosition

  • Tests whether the given position overlaps the interval represented by this object.

    Parameters

    • Optional position: Position

      the position

    Returns boolean

  • Parameters

    • position: Position

      the position where to search for nodes

    • Optional selfContained: boolean

      whether the starting node position contains the positions of all its children. If true: no further search will be performed in subtrees where the root node falls outside the given position.

      • If false (default): the search will cover all nodes from the starting node to the leaves. In any case, the search stops at the first subtree found to be containing the position.

    Returns Generator<Node, any, unknown>

    all nodes containing the given [position] using depth-first search. Empty list if none are found.

  • A generator that walks over the whole AST starting from the children of this node.

    Parameters

    • Optional walker: ((node) => Generator<Node>)

      a function that generates a sequence of nodes. By default, this is the depth-first "walk" function. For post-order traversal, use "walkLeavesFirst".

        • (node): Generator<Node>
        • A generator that walks the whole AST starting from the provided node, depth-first.

          Parameters

          • node: Node

            the starting node.

          Returns Generator<Node>

    Returns Generator<Node, any, unknown>

Generated using TypeDoc