antlr-ng
Version:
Next generation ANTLR Tool
181 lines (180 loc) • 16 kB
TypeScript
import type { IGenerationVariables, ITargetGenerator } from "src/codegen/ITargetGenerator.js";
import type { Action } from "src/codegen/model/Action.js";
import { AddToLabelList } from "src/codegen/model/AddToLabelList.js";
import { AltBlock } from "src/codegen/model/AltBlock.js";
import { CaptureNextToken } from "src/codegen/model/CaptureNextToken.js";
import { CaptureNextTokenType } from "src/codegen/model/CaptureNextTokenType.js";
import { ActionTemplate } from "src/codegen/model/chunk/ActionTemplate.js";
import { ActionText } from "src/codegen/model/chunk/ActionText.js";
import { ArgRef } from "src/codegen/model/chunk/ArgRef.js";
import { LabelRef } from "src/codegen/model/chunk/LabelRef.js";
import { ListLabelRef } from "src/codegen/model/chunk/ListLabelRef.js";
import { LocalRef } from "src/codegen/model/chunk/LocalRef.js";
import { NonLocalAttrRef } from "src/codegen/model/chunk/NonLocalAttrRef.js";
import { QRetValueRef } from "src/codegen/model/chunk/QRetValueRef.js";
import { RetValueRef } from "src/codegen/model/chunk/RetValueRef.js";
import { RulePropertyRefCtx } from "src/codegen/model/chunk/RulePropertyRefCtx.js";
import { RulePropertyRefParser } from "src/codegen/model/chunk/RulePropertyRefParser.js";
import { RulePropertyRefStart } from "src/codegen/model/chunk/RulePropertyRefStart.js";
import { RulePropertyRefStop } from "src/codegen/model/chunk/RulePropertyRefStop.js";
import { RulePropertyRefText } from "src/codegen/model/chunk/RulePropertyRefText.js";
import { SetAttr } from "src/codegen/model/chunk/SetAttr.js";
import { SetNonLocalAttr } from "src/codegen/model/chunk/SetNonLocalAttr.js";
import { ThisRulePropertyRefCtx } from "src/codegen/model/chunk/ThisRulePropertyRefCtx.js";
import { ThisRulePropertyRefParser } from "src/codegen/model/chunk/ThisRulePropertyRefParser.js";
import { ThisRulePropertyRefStart } from "src/codegen/model/chunk/ThisRulePropertyRefStart.js";
import { ThisRulePropertyRefStop } from "src/codegen/model/chunk/ThisRulePropertyRefStop.js";
import { ThisRulePropertyRefText } from "src/codegen/model/chunk/ThisRulePropertyRefText.js";
import { TokenPropertyRefIndex } from "src/codegen/model/chunk/TokenPropertyRefIndex.js";
import { TokenPropertyRefInt } from "src/codegen/model/chunk/TokenPropertyRefInt.js";
import { TokenPropertyRefLine } from "src/codegen/model/chunk/TokenPropertyRefLine.js";
import type { TokenPropertyRefPos } from "src/codegen/model/chunk/TokenPropertyRefPos.js";
import { TokenPropertyRefText } from "src/codegen/model/chunk/TokenPropertyRefText.js";
import { TokenPropertyRefType } from "src/codegen/model/chunk/TokenPropertyRefType.js";
import { TokenRef } from "src/codegen/model/chunk/TokenRef.js";
import type { CodeBlockForAlt } from "src/codegen/model/CodeBlockForAlt.js";
import type { CodeBlockForOuterMostAlt } from "src/codegen/model/CodeBlockForOuterMostAlt.js";
import { AltLabelStructDecl } from "src/codegen/model/decl/AltLabelStructDecl.js";
import { AttributeDecl } from "src/codegen/model/decl/AttributeDecl.js";
import { ContextRuleGetterDecl } from "src/codegen/model/decl/ContextRuleGetterDecl.js";
import { ContextRuleListGetterDecl } from "src/codegen/model/decl/ContextRuleListGetterDecl.js";
import { ContextRuleListIndexedGetterDecl } from "src/codegen/model/decl/ContextRuleListIndexedGetterDecl.js";
import { ContextTokenGetterDecl } from "src/codegen/model/decl/ContextTokenGetterDecl.js";
import { ContextTokenListGetterDecl } from "src/codegen/model/decl/ContextTokenListGetterDecl.js";
import { ContextTokenListIndexedGetterDecl } from "src/codegen/model/decl/ContextTokenListIndexedGetterDecl.js";
import { RuleContextDecl } from "src/codegen/model/decl/RuleContextDecl.js";
import { RuleContextListDecl } from "src/codegen/model/decl/RuleContextListDecl.js";
import { StructDecl } from "src/codegen/model/decl/StructDecl.js";
import { TokenDecl } from "src/codegen/model/decl/TokenDecl.js";
import { TokenListDecl } from "src/codegen/model/decl/TokenListDecl.js";
import { TokenTypeDecl } from "src/codegen/model/decl/TokenTypeDecl.js";
import { ExceptionClause } from "src/codegen/model/ExceptionClause.js";
import { InvokeRule } from "src/codegen/model/InvokeRule.js";
import type { LeftRecursiveRuleFunction } from "src/codegen/model/LeftRecursiveRuleFunction.js";
import type { Lexer } from "src/codegen/model/Lexer.js";
import { LexerFile } from "src/codegen/model/LexerFile.js";
import { ListenerDispatchMethod } from "src/codegen/model/ListenerDispatchMethod.js";
import type { ListenerFile } from "src/codegen/model/ListenerFile.js";
import type { LL1AltBlock } from "src/codegen/model/LL1AltBlock.js";
import { LL1OptionalBlock } from "src/codegen/model/LL1OptionalBlock.js";
import { LL1OptionalBlockSingleAlt } from "src/codegen/model/LL1OptionalBlockSingleAlt.js";
import { LL1PlusBlockSingleAlt } from "src/codegen/model/LL1PlusBlockSingleAlt.js";
import { LL1StarBlockSingleAlt } from "src/codegen/model/LL1StarBlockSingleAlt.js";
import { MatchNotSet } from "src/codegen/model/MatchNotSet.js";
import { MatchSet } from "src/codegen/model/MatchSet.js";
import { MatchToken } from "src/codegen/model/MatchToken.js";
import { OptionalBlock } from "src/codegen/model/OptionalBlock.js";
import type { Parser } from "src/codegen/model/Parser.js";
import type { ParserFile } from "src/codegen/model/ParserFile.js";
import { PlusBlock } from "src/codegen/model/PlusBlock.js";
import type { RuleActionFunction } from "src/codegen/model/RuleActionFunction.js";
import type { RuleFunction } from "src/codegen/model/RuleFunction.js";
import type { RuleSempredFunction } from "src/codegen/model/RuleSempredFunction.js";
import { SemPred } from "src/codegen/model/SemPred.js";
import type { SerializedATN } from "src/codegen/model/SerializedATN.js";
import { StarBlock } from "src/codegen/model/StarBlock.js";
import { TestSetInline } from "src/codegen/model/TestSetInline.js";
import { ThrowNoViableAlt } from "src/codegen/model/ThrowNoViableAlt.js";
import { VisitorDispatchMethod } from "src/codegen/model/VisitorDispatchMethod.js";
import type { VisitorFile } from "src/codegen/model/VisitorFile.js";
import { Wildcard } from "src/codegen/model/Wildcard.js";
export declare class TypeScriptTargetGenerator implements ITargetGenerator {
private static readonly defaultValues;
readonly id = "generator.default.typescript";
readonly language = "TypeScript";
readonly languageSpecifiers: string[];
readonly codeFileExtension = ".ts";
/**
* https://github.com/microsoft/TypeScript/issues/2536
*/
readonly reservedWords: Set<string>;
renderParserFile(parserFile: ParserFile, variables: IGenerationVariables, parser: string, namedActions: Map<string, string>, contextSuperClass: string): string;
renderListenerFile(file: ListenerFile, variables: IGenerationVariables, namedActions: Map<string, string>): string;
renderVisitorFile(file: VisitorFile, variables: IGenerationVariables, namedActions: string): string;
renderParser(parser: Parser, variables: IGenerationVariables, funcs: string, atn: string, sempredFuncs: string, superClass: string): string;
renderRuleActionFunction(r: RuleActionFunction, variables: IGenerationVariables, actions: string): string;
renderRuleSempredFunction(r: RuleSempredFunction, variables: IGenerationVariables, actions: string): string;
renderRuleFunction(currentRule: RuleFunction, variables: IGenerationVariables, args: string, code: string, locals: string, ruleCtx: string, altLabelCtxs: string, namedActions: string, finallyAction: string, postamble: string, exceptions: string): string;
renderLeftRecursiveRuleFunction(currentRule: LeftRecursiveRuleFunction, variables: IGenerationVariables, args: string, code: string, locals: string, ruleCtx: string, altLabelCtxs: string, namedActions: string, finallyAction: string, postamble: string): string;
renderCodeBlockForOuterMostAlt(currentOuterMostAltCodeBlock: CodeBlockForOuterMostAlt, variables: IGenerationVariables, locals: string, preamble: string, ops: string): string;
renderCodeBlockForAlt(currentAltCodeBlock: CodeBlockForAlt, variables: IGenerationVariables, locals: string, preamble: string, ops: string): string;
renderLL1AltBlock(choice: LL1AltBlock, variables: IGenerationVariables, preamble: string, alts: string, error: string): string;
renderLL1OptionalBlock(choice: LL1OptionalBlock, variables: IGenerationVariables, alts: string, error: string): string;
renderLL1OptionalBlockSingleAlt(choice: LL1OptionalBlockSingleAlt, variables: IGenerationVariables, expr: string, alts: string, preamble: string, error: string, followExpr: string): string;
renderLL1StarBlockSingleAlt(choice: LL1StarBlockSingleAlt, variables: IGenerationVariables, loopExpr: string, alts: string, preamble: string, iteration: string): string;
renderLL1PlusBlockSingleAlt(choice: LL1PlusBlockSingleAlt, variables: IGenerationVariables, loopExpr: string, alts: string, preamble: string, iteration: string): string;
renderAltBlock(choice: AltBlock, variables: IGenerationVariables, preamble: string, alts: string, error: string): string;
renderOptionalBlock(choice: OptionalBlock, variables: IGenerationVariables, alts: string, error: string): string;
renderStarBlock(choice: StarBlock, variables: IGenerationVariables, alts: string, sync: string, iteration: string): string;
renderPlusBlock(choice: PlusBlock, variables: IGenerationVariables, alts: string, error: string): string;
renderThrowNoViableAlt(t: ThrowNoViableAlt, variables: IGenerationVariables): string;
renderTestSetInline(s: TestSetInline, variables: IGenerationVariables): string;
renderInvokeRule(r: InvokeRule, variables: IGenerationVariables, argExprsChunks: string): string;
renderMatchToken(m: MatchToken, variables: IGenerationVariables): string;
renderMatchSet(m: MatchSet, variables: IGenerationVariables, expr: string, capture: string): string;
renderMatchNotSet(m: MatchNotSet, variables: IGenerationVariables, expr: string, capture: string): string;
renderWildcard(w: Wildcard, variables: IGenerationVariables): string;
renderAction(a: Action, variables: IGenerationVariables, foo: string, chunks: string): string;
renderArgAction(a: Action, variables: IGenerationVariables, chunks: string): string;
renderSemPred(p: SemPred, variables: IGenerationVariables, chunks: string, failChunks: string): string;
renderExceptionClause(e: ExceptionClause, variables: IGenerationVariables, catchArg: string, catchAction: string): string;
renderLexerSkipCommand(): string;
renderLexerMoreCommand(): string;
renderLexerPopModeCommand(): string;
renderActionText(t: ActionText, variables: IGenerationVariables): string;
renderActionTemplate(t: ActionTemplate, variables: IGenerationVariables): string;
renderArgRef(a: ArgRef, variables: IGenerationVariables): string;
renderLocalRef(a: LocalRef, variables: IGenerationVariables): string;
renderRetValueRef(a: RetValueRef, variables: IGenerationVariables): string;
renderQRetValueRef(a: QRetValueRef, variables: IGenerationVariables): string;
renderTokenRef(t: TokenRef, variables: IGenerationVariables): string;
renderLabelRef(t: LabelRef, variables: IGenerationVariables): string;
renderListLabelRef(t: ListLabelRef, variables: IGenerationVariables): string;
renderSetAttr(s: SetAttr, variables: IGenerationVariables, rhsChunks: string): string;
renderTokenLabelType(): string;
renderInputSymbolType(): string;
renderTokenPropertyRefText(t: TokenPropertyRefText, variables: IGenerationVariables): string;
renderTokenPropertyRefType(t: TokenPropertyRefType, variables: IGenerationVariables): string;
renderTokenPropertyRefLine(t: TokenPropertyRefLine, variables: IGenerationVariables): string;
renderTokenPropertyRefPos(t: TokenPropertyRefPos, variables: IGenerationVariables): string;
renderTokenPropertyRefChannel(t: TokenPropertyRefPos, variables: IGenerationVariables): string;
renderTokenPropertyRefIndex(t: TokenPropertyRefIndex, variables: IGenerationVariables): string;
renderTokenPropertyRefInt(t: TokenPropertyRefInt, variables: IGenerationVariables): string;
renderRulePropertyRefStart(r: RulePropertyRefStart, variables: IGenerationVariables): string;
renderRulePropertyRefStop(r: RulePropertyRefStop, variables: IGenerationVariables): string;
renderRulePropertyRefText(r: RulePropertyRefText, variables: IGenerationVariables): string;
renderRulePropertyRefCtx(r: RulePropertyRefCtx, variables: IGenerationVariables): string;
renderRulePropertyRefParser(r: RulePropertyRefParser, variables: IGenerationVariables): string;
renderThisRulePropertyRefStart(r: ThisRulePropertyRefStart, variables: IGenerationVariables): string;
renderThisRulePropertyRefStop(r: ThisRulePropertyRefStop, variables: IGenerationVariables): string;
renderThisRulePropertyRefText(r: ThisRulePropertyRefText, variables: IGenerationVariables): string;
renderThisRulePropertyRefCtx(r: ThisRulePropertyRefCtx, variables: IGenerationVariables): string;
renderThisRulePropertyRefParser(r: ThisRulePropertyRefParser, variables: IGenerationVariables): string;
renderNonLocalAttrRef(s: NonLocalAttrRef, variables: IGenerationVariables): string;
renderSetNonLocalAttr(s: SetNonLocalAttr, variables: IGenerationVariables, rhsChunks: string): string;
renderAddToLabelList(a: AddToLabelList, variables: IGenerationVariables): string;
renderTokenDecl(t: TokenDecl, variables: IGenerationVariables): string;
renderTokenTypeDecl(t: TokenTypeDecl, variables: IGenerationVariables): string;
renderTokenListDecl(t: TokenListDecl, variables: IGenerationVariables): string;
renderRuleContextDecl(r: RuleContextDecl, variables: IGenerationVariables): string;
renderRuleContextListDecl(rdecl: RuleContextListDecl, variables: IGenerationVariables): string;
renderContextTokenGetterDecl(t: ContextTokenGetterDecl, variables: IGenerationVariables): string;
renderContextTokenListGetterDecl(t: ContextTokenListGetterDecl, variables: IGenerationVariables): string;
renderContextTokenListIndexedGetterDecl(t: ContextTokenListIndexedGetterDecl, variables: IGenerationVariables): string;
renderContextRuleGetterDecl(r: ContextRuleGetterDecl, variables: IGenerationVariables): string;
renderContextRuleListGetterDecl(r: ContextRuleListGetterDecl, variables: IGenerationVariables): string;
renderContextRuleListIndexedGetterDecl(r: ContextRuleListIndexedGetterDecl, variables: IGenerationVariables): string;
renderLexerRuleContext(): string;
renderRuleContextNameSuffix(): string;
renderCaptureNextToken(d: CaptureNextToken, variables: IGenerationVariables): string;
renderCaptureNextTokenType(d: CaptureNextTokenType, variables: IGenerationVariables): string;
renderStructDecl(struct: StructDecl, variables: IGenerationVariables, ctorAttrs: string, attrs: string, getters: string, dispatchMethods: string, interfaces: string, extensionMembers: string, signatures: string): string;
renderAltLabelStructDecl(struct: AltLabelStructDecl, variables: IGenerationVariables, attrs: string, getters: string, dispatchMethods: string): string;
renderListenerDispatchMethod(method: ListenerDispatchMethod, variables: IGenerationVariables): string;
renderVisitorDispatchMethod(method: VisitorDispatchMethod, variables: IGenerationVariables): string;
renderAttributeDecl(d: AttributeDecl, variables: IGenerationVariables): string;
renderLexerFile(lexerFile: LexerFile, variables: IGenerationVariables, lexer: string, namedActions: string): string;
renderLexer(lexer: Lexer, variables: IGenerationVariables, atn: string, actionFuncs: string, sempredFuncs: string, superClass: string): string;
renderSerializedATN(model: SerializedATN, variables: IGenerationVariables): string;
private initValue;
}