Langium - v4.4.0
    Preparing search index...

    Class CstNodeBuilder

    Incrementally builds the concrete syntax tree (CST) while the parser processes the input.

    The parser drives the builder with the following protocol: buildRootNode starts a new tree, buildCompositeNode opens a nested node whenever a parser rule is invoked, buildLeafNode adds a node for every consumed token, and construct closes the innermost open composite node once its rule implementation has finished. Hidden tokens (e.g. comments and whitespace) are not part of the parser's token stream and are added separately via addHiddenNodes.

    Index
    • Insert leaf nodes for hidden tokens (e.g. comments) into the tree. Since hidden tokens are not part of the parser's token stream, the parser calls this separately: once before each consumed token with the hidden tokens preceding it, and once after parsing for the trailing hidden tokens. The nodes are attached where the tree is currently being built, so hidden nodes end up next to the non-hidden token that follows them.

      Parameters

      • tokens: IToken[]

      Returns void

    • Close the current composite node and assign it to the given AST node (item.$cstNode). The parser calls this when a rule implementation has finished, matching the preceding buildCompositeNode (or buildRootNode) call; the parent node becomes current again. If the closed node has no content, e.g. due to an unsuccessful optional rule call, it is removed from the tree.

      Parameters

      • item: { $cstNode: CstNode; $infixName?: string; $type: string | symbol | undefined }

      Returns void