UNPKG

antlr4ng

Version:

Alternative JavaScript/TypeScript runtime for ANTLR4

53 lines (52 loc) 2.35 kB
export declare class Vocabulary { static readonly EMPTY_NAMES: string[]; /** * Gets an empty {@link Vocabulary} instance. * * * No literal or symbol names are assigned to token types, so * {@link #getDisplayName(int)} returns the numeric value for all tokens * except {@link Token#EOF}. */ static readonly EMPTY_VOCABULARY: Vocabulary; readonly maxTokenType: number; private readonly literalNames; private readonly symbolicNames; private readonly displayNames; /** * Constructs a new instance of {@link Vocabulary} from the specified * literal, symbolic, and display token names. * * @param literalNames The literal names assigned to tokens, or `null` * if no literal names are assigned. * @param symbolicNames The symbolic names assigned to tokens, or * `null` if no symbolic names are assigned. * @param displayNames The display names assigned to tokens, or `null` * to use the values in `literalNames` and `symbolicNames` as * the source of display names, as described in * {@link #getDisplayName(int)}. */ constructor(literalNames: Array<string | null>, symbolicNames: Array<string | null>, displayNames?: Array<string | null> | null); /** * Returns a {@link Vocabulary} instance from the specified set of token * names. This method acts as a compatibility layer for the single * `tokenNames` array generated by previous releases of ANTLR. * * The resulting vocabulary instance returns `null` for * {@link getLiteralName getLiteralName(int)} and {@link getSymbolicName getSymbolicName(int)}, and the * value from `tokenNames` for the display names. * * @param tokenNames The token names, or `null` if no token names are * available. * @returns A {@link Vocabulary} instance which uses `tokenNames` for * the display names of tokens. */ static fromTokenNames(tokenNames: Array<string | null> | null): Vocabulary; getMaxTokenType(): number; getLiteralName(tokenType: number): string | null; getSymbolicName(tokenType: number): string | null; getDisplayName(tokenType: number): string | null; getLiteralNames(): Array<string | null>; getSymbolicNames(): Array<string | null>; getDisplayNames(): Array<string | null>; }