UNPKG

antlr-ng

Version:

Next generation ANTLR Tool

51 lines (50 loc) 2.47 kB
import { ATN, LexerAction } from "antlr4ng"; import { CodeGenerator } from "../codegen/CodeGenerator.js"; import { LexerGrammar } from "../tool/LexerGrammar.js"; import { ActionAST } from "../tool/ast/ActionAST.js"; import { GrammarAST } from "../tool/ast/GrammarAST.js"; import { TerminalAST } from "../tool/ast/TerminalAST.js"; import type { IStatePair } from "./IATNFactory.js"; import { ParserATNFactory } from "./ParserATNFactory.js"; export declare class LexerATNFactory extends ParserATNFactory { private codegenTemplates; /** Maps from an action index to a {@link LexerAction} object. */ private indexToActionMap; /** Maps from a {@link LexerAction} object to the action index. */ private actionToIndexMap; private readonly ruleCommands; constructor(g: LexerGrammar, codeGenerator?: CodeGenerator); createATN(): ATN; rule(ruleAST: GrammarAST, name: string, blk: IStatePair): IStatePair; action(action: ActionAST | string): IStatePair; action(node: GrammarAST, lexerAction: LexerAction): IStatePair; lexerAltCommands(alt: IStatePair, commands: IStatePair): IStatePair; lexerCallCommand(id: GrammarAST, arg: GrammarAST): IStatePair; lexerCommand(id: GrammarAST): IStatePair; range(a: GrammarAST, b: GrammarAST): IStatePair; set(associatedAST: GrammarAST, alts: GrammarAST[], invert: boolean): IStatePair; /** * For a lexer, a string is a sequence of char to match. That is, "fog" is treated as 'f' 'o' 'g' not as a * single transition in the DFA. Machine== o-'f'->o-'o'->o-'g'->o and has n+1 states for n characters. * If "caseInsensitive" option is enabled, "fog" will be treated as o-('f'|'F') -> o-('o'|'O') -> o-('g'|'G'). */ stringLiteral(stringLiteralAST: TerminalAST): IStatePair; /** `[Aa\t \u1234a-z\]\p{Letter}\-]` char sets */ charSetLiteral(charSetAST: GrammarAST): IStatePair; tokenRef(node: TerminalAST): IStatePair | null; private getSetFromCharSetLiteral; private getLexerActionIndex; private checkRange; private lexerCallCommandOrCommand; private applyPrevStateAndMoveToCodePoint; private applyPrevStateAndMoveToProperty; private applyPrevState; private checkCharAndAddToSet; private checkRangeAndAddToSet; private createTransition; private createLexerAction; private checkCommands; private getModeConstantValue; private getTokenConstantValue; private getChannelConstantValue; }