antlr-ng
Version:
Next generation ANTLR Tool
30 lines (29 loc) • 1.63 kB
TypeScript
import { IntervalSet } from "antlr4ng";
import { GrammarAST } from "../../tool/ast/GrammarAST.js";
import { IOutputModelFactory } from "../IOutputModelFactory.js";
import { CodeBlockForAlt } from "./CodeBlockForAlt.js";
import { RuleElement } from "./RuleElement.js";
import { SrcOp } from "./SrcOp.js";
import { TestSetInline } from "./TestSetInline.js";
import { ThrowNoViableAlt } from "./ThrowNoViableAlt.js";
import { ITokenInfo } from "./ITokenInfo.js";
import { Decl } from "./decl/Decl.js";
/**
* The class hierarchy underneath SrcOp is pretty deep but makes sense that, for example LL1StarBlock is a kind of
* LL1Loop which is a kind of Choice. The problem is it's impossible to figure out how to construct one of these
* deeply nested objects because of the long super constructor call chain. Instead, I decided to in-line all of
* this and then look for opportunities to re-factor code into functions. It makes sense to use a class hierarchy
* to share data fields, but I don't think it makes sense to factor code using super constructors because
* it has too much work to do.
*/
export declare abstract class Choice extends RuleElement {
decision: number;
label: Decl;
alts: CodeBlockForAlt[];
preamble: SrcOp[];
constructor(factory: IOutputModelFactory, blkOrEbnfRootAST: GrammarAST, alts: CodeBlockForAlt[]);
addPreambleOp(op: SrcOp): void;
getAltLookaheadAsStringLists(altLookSets: IntervalSet[]): ITokenInfo[][];
addCodeForLookaheadTempVar(look: IntervalSet): TestSetInline | null;
getThrowNoViableAlt(factory: IOutputModelFactory, blkAST: GrammarAST): ThrowNoViableAlt;
}