parserlib
    Preparing search index...

    Interface ParseTree<NT>

    Represents an immutable parse tree.

    Each node represents the application of a production rule from the grammar, name ::= expr.

    The node's name() is the nonterminal on the left side of the production rule, and the node's children() are the production rules that were matched for each nonterminal used in the righthand side (expr).

    A node also has text() representing the substring matched by this node's subtree, and start()/end() indicating where that substring is relative to the entire string parsed.

    If the grammar used @skip to skip over some nonterminals automatically, then the skipped subtrees do not appear among this node's children(), but can be found by using allChildren() or childrenByName().

    interface ParseTree<NT> {
        allChildren: readonly ParseTree<NT>[];
        children: readonly ParseTree<NT>[];
        end: number;
        isSkipped: boolean;
        name: NT;
        start: number;
        text: string;
        childrenByName(name: NT): readonly ParseTree<NT>[];
    }

    Type Parameters

    • NT

      a Typescript Enum with one symbol for each nonterminal used in the grammar, matching the nonterminals when compared case-insensitively (so ROOT and Root and root are the same).

    Index

    Properties

    allChildren: readonly ParseTree<NT>[]

    Get all of this node's children, including

    rules.

    an immutable array of all the children of this node, in order, including

    subtrees

    children: readonly ParseTree<NT>[]

    Get this node's children.

    an immutable array of the children of this node, in order, excluding

    subtrees

    end: number

    Get the offset where this subtree ends in the entire parsed string.

    the offset [0,...length-1] in the entire parsed string where this subtree ends

    isSkipped: boolean

    Test if this node is in a subtree that was @skipped.

    true iff this node is part of a subtree that was automatically skipped over by a

    rule.

    name: NT

    Get this node's name.

    the nonterminal corresponding to this node in the parse tree.

    start: number

    Get the offset where this subtree starts in the entire parsed string.

    the offset [0,...length-1] in the entire parsed string where this subtree started to match

    text: string

    Get this subtree's text.

    the substring of the entire parsed string that this subtree matched

    Methods

    • Get the children that correspond to a particular production rule.

      Parameters

      • name: NT

        name of the nonterminal corresponding to the desired production rule.

      Returns readonly ParseTree<NT>[]

      an immutable array of the children that represent matches of name's production rule, in order.