antlr-ng
Version:
Next generation ANTLR Tool
55 lines (54 loc) • 2.46 kB
TypeScript
import { ATNState, OrderedHashSet } from "antlr4ng";
import { FrequencySet } from "../../misc/FrequencySet.js";
import { Rule } from "../../tool/Rule.js";
import { AltAST } from "../../tool/ast/AltAST.js";
import { GrammarAST } from "../../tool/ast/GrammarAST.js";
import { IOutputModelFactory } from "../IOutputModelFactory.js";
import { Action } from "./Action.js";
import { ExceptionClause } from "./ExceptionClause.js";
import { OutputModelObject } from "./OutputModelObject.js";
import { SrcOp } from "./SrcOp.js";
import { AltLabelStructDecl } from "./decl/AltLabelStructDecl.js";
import { AttributeDecl } from "./decl/AttributeDecl.js";
import { Decl } from "./decl/Decl.js";
import { StructDecl } from "./decl/StructDecl.js";
export declare class RuleFunction extends OutputModelObject {
readonly name: string;
readonly escapedName: string;
readonly modifiers: string[];
ctxType: string;
readonly ruleLabels: Set<string> | null;
readonly tokenLabels: Set<string>;
readonly startState: ATNState;
readonly index: number;
readonly rule: Rule;
readonly altToContext: AltLabelStructDecl[];
hasLookaheadBlock: boolean;
code: SrcOp[];
readonly locals: OrderedHashSet<Decl>;
args?: AttributeDecl[];
ruleCtx: StructDecl;
altLabelCtxs?: Map<string, AltLabelStructDecl>;
namedActions: Map<string, Action> | undefined;
finallyAction: Action | undefined;
exceptions: ExceptionClause[] | undefined;
postamble: SrcOp[] | undefined;
constructor(factory: IOutputModelFactory, r: Rule);
addContextGetters(factory: IOutputModelFactory, r: Rule): void;
fillNamedActions(factory: IOutputModelFactory, r: Rule): void;
/**
* For all alts, find which ref X or r needs List. Must see across alts.
* If any alt needs X or r as list, then define as list.
*/
getDeclsForAllElements(altASTs: AltAST[]): Set<Decl>;
getDeclForAltElement(t: GrammarAST, refLabelName: string, needList: boolean, optional: boolean): Decl[];
/** Add local var decl */
addLocalDecl(d: Decl): void;
/** Add decl to struct ctx for rule or alt if labeled. */
addContextDecl(altLabel: string, d: Decl): void;
/** Given list of X and r refs in alt, compute how many of each there are. */
protected getElementFrequenciesForAlt(ast: AltAST): [FrequencySet<string>, FrequencySet<string>];
private getRuleTokens;
private getName;
private nodesToStrings;
}