The composite node currently being built, i.e. the one to which new child nodes are added:
the innermost parser rule invocation that has not been completed with construct yet.
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.
Append a child node to the content of a composite node and set the child's container reference.
Append multiple child nodes to the content of a composite node and set their container references.
Create a composite node as a child of the current node and make it the new current node.
The parser calls this when a rule is invoked that creates its own AST node; the node
remains current until the corresponding construct call closes it.
Create a leaf node for a consumed token and append it to the current composite node. If no grammar element is given, the token is treated as hidden (e.g. a comment).
Optionalfeature: GrammarAST.AbstractElementReset the builder and create the root node of a new tree. This must be called once before each parser run; all nodes built afterwards belong to the returned root.
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.
ProtectedcreateCreate a detached leaf node from a token, translating Chevrotain's position information to the LSP conventions used by the CST.
Insert child nodes at the given index into the content of a composite node and set their container references.
Incrementally builds the concrete syntax tree (CST) while the parser processes the input.
The parser drives the builder with the following protocol:
buildRootNodestarts a new tree,buildCompositeNodeopens a nested node whenever a parser rule is invoked,buildLeafNodeadds a node for every consumed token, andconstructcloses 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 viaaddHiddenNodes.