Interface BaseParser

Base interface for all parsers. Mainly used by the parser-builder-base.ts to perform work on different kinds of parsers. The main use cases are:

  • AST parser: Based on a string, create an AST for the current grammar
  • Completion parser: Based on a partial string, identify the current position of the input within the grammar
interface BaseParser {
    get unorderedGroups(): Map<string, boolean[]>;
    action($type: string, action: GrammarAST.Action): void;
    alternatives(idx: number, choices: IOrAlt<any>[]): void;
    atLeastOne(idx: number, callback: DSLMethodOpts<unknown>): void;
    construct(): unknown;
    consume(idx: number, tokenType: TokenType, feature: GrammarAST.AbstractElement): void;
    getRule(name: string): undefined | RuleResult;
    getRuleStack(): number[];
    isRecording(): boolean;
    many(idx: number, callback: DSLMethodOpts<unknown>): void;
    optional(idx: number, callback: DSLMethodOpts<unknown>): void;
    rule(rule: GrammarAST.ParserRule, impl: RuleImpl): RuleResult;
    subrule(idx: number, rule: RuleResult, feature: GrammarAST.AbstractElement, args: Args): void;
}

Implemented by

Accessors

Methods

  • Whether the parser is currently actually in use or in "recording mode". Recording mode is activated once when the parser is analyzing itself. During this phase, no input exists and therefore no AST should be constructed

    Returns boolean

  • Invokes the executable function for a given parser rule. Requires a unique index within the rule for a specific sub rule. Arguments can be supplied to the rule invocation for semantic predicates

    Parameters

    Returns void