antlr-ng
Version:
Next generation ANTLR Tool
78 lines (77 loc) • 4.27 kB
TypeScript
import type { IToolParameters } from "../tool-parameters.js";
import { Alternative } from "../tool/Alternative.js";
import { Grammar } from "../tool/Grammar.js";
import { LeftRecursiveRule } from "../tool/LeftRecursiveRule.js";
import { Rule } from "../tool/Rule.js";
import { ActionAST } from "../tool/ast/ActionAST.js";
import { BlockAST } from "../tool/ast/BlockAST.js";
import { GrammarAST } from "../tool/ast/GrammarAST.js";
import { IOutputModelFactory } from "./IOutputModelFactory.js";
import { Choice } from "./model/Choice.js";
import { CodeBlockForAlt } from "./model/CodeBlockForAlt.js";
import { ILabeledOp } from "./model/ILabeledOp.js";
import { LeftRecursiveRuleFunction } from "./model/LeftRecursiveRuleFunction.js";
import { Lexer } from "./model/Lexer.js";
import { LexerFile } from "./model/LexerFile.js";
import { OutputModelObject } from "./model/OutputModelObject.js";
import { Parser } from "./model/Parser.js";
import { ParserFile } from "./model/ParserFile.js";
import { RuleFunction } from "./model/RuleFunction.js";
import { SrcOp } from "./model/SrcOp.js";
import { CodeBlock } from "./model/decl/CodeBlock.js";
/**
* This receives events from SourceGenTriggers.g and asks factory to do work. Then runs extensions in order on
* resulting SrcOps to get final list.
*/
export declare class OutputModelController {
/** Who does the work? */
readonly factory: IOutputModelFactory;
currentBlock: CodeBlock;
currentOuterMostAlt: Alternative;
/** While walking code in rules, this is set to the tree walker that triggers actions. */
private walker;
private currentRuleStack;
private errorManager;
constructor(factory: IOutputModelFactory);
/**
* Build a file with a parser containing rule functions. Use the controller as factory in SourceGenTriggers so
* it triggers codegen extensions too, not just the factory functions in this factory.
*/
buildParserOutputModel(header: boolean, toolParameters: IToolParameters): OutputModelObject;
buildLexerOutputModel(header: boolean, toolParameters: IToolParameters): OutputModelObject;
buildListenerOutputModel(header: boolean): OutputModelObject;
buildBaseListenerOutputModel(header: boolean): OutputModelObject;
buildVisitorOutputModel(header: boolean): OutputModelObject;
buildBaseVisitorOutputModel(header: boolean): OutputModelObject;
parserFile(fileName: string, toolParameters: IToolParameters): ParserFile;
parser(file: ParserFile): Parser;
lexerFile(fileName: string, toolParameters: IToolParameters): LexerFile;
lexer(file: LexerFile): Lexer;
/**
* Create RuleFunction per rule and update sempreds,actions of parser output object with stuff found in r.
*/
buildRuleFunction(parser: Parser, r: Rule): void;
buildLeftRecursiveRuleFunction(r: LeftRecursiveRule, ruleFunction: LeftRecursiveRuleFunction): void;
buildNormalRuleFunction(r: Rule, ruleFunction: RuleFunction): void;
buildLexerRuleActions(lexer: Lexer, r: Rule): void;
rule(r: Rule): RuleFunction;
rulePostamble(ruleFunction: RuleFunction, r: Rule): SrcOp[];
getGrammar(): Grammar;
alternative(alt: Alternative, outerMost: boolean): CodeBlockForAlt;
finishAlternative(blk: CodeBlockForAlt, ops: SrcOp[], outerMost: boolean): CodeBlockForAlt;
ruleRef(id: GrammarAST, label: GrammarAST | null, args: GrammarAST | null): SrcOp[];
tokenRef(id: GrammarAST, label: GrammarAST | null, args: GrammarAST | null): SrcOp[];
stringRef(id: GrammarAST, label: GrammarAST | null): SrcOp[];
/** (A|B|C) possibly with ebnfRoot and label. */
set(setAST: GrammarAST, labelAST: GrammarAST | null, invert: boolean): SrcOp[];
epsilon(alt: Alternative, outerMost: boolean): CodeBlockForAlt;
wildcard(ast: GrammarAST, labelAST: GrammarAST | null): SrcOp[];
action(ast: ActionAST): SrcOp[];
sempred(ast: ActionAST): SrcOp[];
getChoiceBlock(blkAST: BlockAST, alts: CodeBlockForAlt[], label: GrammarAST | null): Choice;
getEBNFBlock(ebnfRoot: GrammarAST | null, alts: CodeBlockForAlt[]): Choice;
needsImplicitLabel(id: GrammarAST, op: ILabeledOp): boolean;
get currentRuleFunction(): RuleFunction | undefined;
private pushCurrentRule;
private popCurrentRule;
}