Langium - v4.0.0
    Preparing search index...

    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;
        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.InfixRule | GrammarAST.ParserRule,
            impl: RuleImpl,
        ): RuleResult;
        subrule(
            idx: number,
            rule: RuleResult,
            fragment: boolean,
            feature: GrammarAST.AbstractElement,
            args: Args,
        ): void;
    }

    Implemented by

    Index

    Accessors

    Methods

    • Parses the callback 1 or more times (the + operation in EBNF/Langium)

      Parameters

      • idx: number
      • callback: DSLMethodOpts<unknown>

      Returns void

    • 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

    • Parses the callback 0 or more times (the * operation in EBNF/Langium)

      Parameters

      • idx: number
      • callback: DSLMethodOpts<unknown>

      Returns void

    • Parses the callback as optional (the ? operation in EBNF/Langium)

      Parameters

      • idx: number
      • callback: DSLMethodOpts<unknown>

      Returns void

    • 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