Hierarchy (view full)

Constructors

Properties

children: ParseTree[]
invokingState: number

What state invoked the rule associated with this context? The "return address" is the followState of invokingState If parent is null, this should be -1 this context object represents the start rule.

parent: ParserRuleContext

The parent of this node. If the return value is null, then this node is the root of the tree.

start: Token
stop: Token
empty: ParserRuleContext

Accessors

  • get ruleContext(): ParserRuleContext
  • Returns ParserRuleContext

Methods

  • Parameters

    • child: ParserRuleContext

    Returns ParserRuleContext

  • For rule associated with this parse tree internal node, return the outer alternative number used to match the input. Default implementation does not compute nor store this alt num. Create a subclass of ParserRuleContext with backing field and set option contextSuperClass. to set it.

    Returns number

  • If there are children, get the ith value indexed from 0.

    Parameters

    • i: number

    Returns ParseTree

  • Type Parameters

    • T extends ParseTree

    Parameters

    • i: number
    • type: (new (...args: unknown[]) => T)
        • new (...args): T
        • Parameters

          • Rest...args: unknown[]

          Returns T

    Returns T

  • How many children are there? If there is none, then this node represents a leaf node.

    Returns number

  • This method returns whatever object represents the data at this node. For example, for parse trees, the payload can be a Token representing a leaf node or a RuleContext object representing a rule invocation. For abstract syntax trees (ASTs), this is a Token object.

    Returns ParserRuleContext

  • Type Parameters

    • T extends ParserRuleContext
    • Args extends unknown[]

    Parameters

    • index: number
    • ctxType: (new (...args: Args) => T)
        • new (...args): T
        • Parameters

          Returns T

    Returns T

  • Type Parameters

    • T extends ParserRuleContext
    • Args extends unknown[]

    Parameters

    • ctxType: (new (...args: Args) => T)
        • new (...args): T
        • Parameters

          Returns T

    Returns T[]

  • Return an Interval indicating the index in the TokenStream of the first and last token associated with this subtree. If this node is a leaf, then the interval represents a single token and has interval i..i for token index i.

    An interval of i..i-1 indicates an empty interval at position i in the input stream, where 0 <= i <= the size of the input token stream. Currently, the code base can only have i=0..n-1 but in concept one could have an empty interval after EOF.

    If source interval is unknown, this returns Interval.INVALID.

    As a weird special case, the source interval for rules matched after EOF is unspecified.

    Returns Interval

  • Return the combined text of all leaf nodes. Does not get any off-channel tokens (if any) so won't return whitespace and comments if they are sent to parser on hidden channel.

    Returns string

  • Parameters

    • ttype: number
    • i: number

    Returns TerminalNode

  • A context is empty if there is no invoking state; meaning nobody call current context.

    Returns boolean

  • Used by enterOuterAlt to toss out a RuleContext previously added as we entered a rule. If we have label, we will need to remove generic ruleContext object.

    Returns void

  • Set the outer alternative number for this context node. Default implementation does nothing to avoid backing field overhead for trees that don't need it. Create a subclass of ParserRuleContext with backing field and set option contextSuperClass.

    Parameters

    • _altNumber: number

    Returns void

  • Returns a string representation of an object.

    Parameters

    • OptionalruleNames: string[]
    • Optionalstop: ParserRuleContext

    Returns string

  • Print out a whole tree, not just a node, in LISP format (root child1 .. childN). Print just a node if this is a leaf.

    Parameters

    • Optionalrecog: Parser

    Returns string

  • Parameters

    • ruleNames: string[]
    • recog: Parser

    Returns string