Interface ILookaheadStrategyExperimental

Hierarchy

  • ILookaheadStrategy

Methods

  • buildLookaheadForAlternation(options: { dynamicTokensEnabled: boolean; hasPredicates: boolean; maxLookahead: number; prodOccurrence: number; rule: Rule }): ((orAlts?: IOrAlt<any>[]) => undefined | number)
  • Builds a lookahead function for alternations/OR parser methods.

    Returns

    A function that is able to compute which of the alternatives to choose while parsing.

    Parameters

    • options: { dynamicTokensEnabled: boolean; hasPredicates: boolean; maxLookahead: number; prodOccurrence: number; rule: Rule }
      • dynamicTokensEnabled: boolean

        Whether dynamic tokens are enabled for this parser.

      • hasPredicates: boolean

        Whether any of the alternatives contain a predicate.

      • maxLookahead: number

        The maximum amount of lookahead for this OR.

      • prodOccurrence: number

        The occurrence number of this OR within its rule.

      • rule: Rule

        The rule that contains this OR.

    Returns ((orAlts?: IOrAlt<any>[]) => undefined | number)

      • (orAlts?: IOrAlt<any>[]): undefined | number
      • Builds a lookahead function for alternations/OR parser methods.

        Returns

        A function that is able to compute which of the alternatives to choose while parsing.

        Parameters

        • Optional orAlts: IOrAlt<any>[]

        Returns undefined | number

  • buildLookaheadForOptional(options: { dynamicTokensEnabled: boolean; maxLookahead: number; prodOccurrence: number; prodType: OptionalProductionType; rule: Rule }): (() => boolean)
  • Builds a lookahead function for optional productions.

    Returns

    A function is able to compute whether to parse the production or to continue with the rest of the parser rule.

    Parameters

    • options: { dynamicTokensEnabled: boolean; maxLookahead: number; prodOccurrence: number; prodType: OptionalProductionType; rule: Rule }
      • dynamicTokensEnabled: boolean

        Whether dynamic tokens are enabled for this parser.

      • maxLookahead: number

        The maximum amount of lookahead for this production.

      • prodOccurrence: number

        The occurrence number of this production within its rule.

      • prodType: OptionalProductionType

        The type of this production.

      • rule: Rule

        The rule that contains this production.

    Returns (() => boolean)

      • (): boolean
      • Builds a lookahead function for optional productions.

        Returns

        A function is able to compute whether to parse the production or to continue with the rest of the parser rule.

        Returns boolean

  • initialize(options: { rules: Rule[] }): void
  • Initializes the lookahead for a grammar.

    Note that this method does not build the lookahead functions. It only initializes the internal state of the strategy based on all grammar rules.

    Parameters

    • options: { rules: Rule[] }
      • rules: Rule[]

        All parser rules of the grammar.

    Returns void

  • Performs validations on the grammar specific to this lookahead strategy. This method is not called if parser validations are disabled.

    Parameters

    • options: { grammarName: string; rules: Rule[]; tokenTypes: TokenType[] }
      • grammarName: string

        The name of the grammar.

      • rules: Rule[]

        All parser rules of the grammar.

      • tokenTypes: TokenType[]

        All token types of the grammar.

    Returns ILookaheadValidationError[]

Generated using TypeDoc