Class ASTCursor

AST cursor.

A cursor is used to traverse the AST.

Constructors

  • Constructs a new AST cursor.

    Parameters

    • root: AST

      The root node.

    • parser: TranslationUnitLike

      The parser that owns the AST.

    Returns ASTCursor

Properties

root: AST

The root node.

Accessors

Methods

  • Move the cursor to the first child of the current node.

    Returns boolean

  • Move the cursor to the next sibling of the current node.

    Returns boolean

  • Move the cursor to the parent of the current node.

    Returns boolean

  • Pre-order traversal of the AST.

    Returns Generator<
        { depth: number; node: Token
        | AST; slot: undefined | ASTSlot },
        void,
        unknown,
    >

    A generator that yields the nodes in pre-order.