antlr-ng
Version:
Next generation ANTLR Tool
51 lines (50 loc) • 1.84 kB
TypeScript
import { ILeftRecursiveRuleAltInfo } from "../analysis/ILeftRecursiveRuleAltInfo.js";
import { OrderedHashMap } from "../misc/OrderedHashMap.js";
import { Grammar } from "./Grammar.js";
import { Rule } from "./Rule.js";
import { AltAST } from "./ast/AltAST.js";
import type { GrammarAST } from "./ast/GrammarAST.js";
import { RuleAST } from "./ast/RuleAST.js";
export declare class LeftRecursiveRule extends Rule {
/** Did we delete any labels on direct left-recur refs? Points at ID of ^(= ID el) */
leftRecursiveRuleRefLabels: [GrammarAST, string | undefined][];
recPrimaryAlts: ILeftRecursiveRuleAltInfo[];
recOpAlts: OrderedHashMap<number, ILeftRecursiveRuleAltInfo>;
private originalAST;
constructor(g: Grammar, name: string, ast: RuleAST);
hasAltSpecificContexts(): boolean;
getOriginalNumberOfAlts(): number;
getOriginalAST(): RuleAST;
getUnlabeledAltASTs(): AltAST[] | null;
/**
* @returns an array that maps predicted alt from primary decision to original alt of rule. For following rule,
* returns [0, 2, 4]
*
* ```antlr
* e : e '*' e
* | INT
* | e '+' e
* | ID
* ;
* ```
*
* That maps predicted alt 1 to original alt 2 and predicted 2 to alt 4.
*/
getPrimaryAlts(): number[];
/**
* @returns an array that maps predicted alt from recursive op decision to original alt of rule. For following rule,
* returns [0, 1, 3]
*
* ```antlr
* e : e '*' e
* | INT
* | e '+' e
* | ID
* ;
* ```
* That maps predicted alt 1 to original alt 1 and predicted 2 to alt 3.
*/
getRecursiveOpAlts(): number[];
/** @returns labels from those alts we deleted for left-recursive rules. */
getAltLabels(): Map<string, Array<[number, AltAST]>> | null;
}