UNPKG

antlr-ng

Version:

Next generation ANTLR Tool

62 lines (61 loc) 3.15 kB
import { GrammarTreeVisitor } from "../../tree/walkers/GrammarTreeVisitor.js"; import { FrequencySet } from "../../misc/FrequencySet.js"; import { ActionAST } from "../../tool/ast/ActionAST.js"; import { GrammarAST } from "../../tool/ast/GrammarAST.js"; import { TerminalAST } from "../../tool/ast/TerminalAST.js"; export declare class ElementFrequenciesVisitor extends GrammarTreeVisitor { /** * This special value means "no set", and is used by {@link minFrequencies} to ensure that {@link combineMin} * doesn't merge an empty set (all zeros) with the results of the first alternative. */ private static readonly sentinel; readonly frequencies: Array<FrequencySet<string>>; readonly minFrequencies: Array<FrequencySet<string>>; /** * Generate a frequency set as the union of two input sets. If an element is contained in both sets, the value * for the output will be the maximum of the two input values. * * @param a The first set. * @param b The second set. * * @returns The union of the two sets, with the maximum value chosen whenever both sets contain the same key. */ protected static combineMax(a: FrequencySet<string>, b: FrequencySet<string>): FrequencySet<string>; /** * Generate a frequency set as the union of two input sets. If an element is contained in both sets, the value * for the output will be the minimum of the two input values. * * @param a The first set. * @param b The second set. If this set is {@link sentinel}, it is treated as though no second set were provided. * * @returns The union of the two sets, with the minimum value chosen whenever both sets contain the same key. */ protected static combineMin(a: FrequencySet<string>, b: FrequencySet<string>): FrequencySet<string>; /** * Generate a frequency set as the union of two input sets, with the values clipped to a specified maximum value. * If an element is contained in both sets, the value for the output, prior to clipping, will be the sum of the * two input values. * * @param a The first set. * @param b The second set. * @param clip The maximum value to allow for any output. * * @returns The sum of the two sets, with the individual elements clipped to the maximum value given by `clip`. */ protected static combineAndClip(a: FrequencySet<string>, b: FrequencySet<string>, clip: number): FrequencySet<string>; protected tokenRef(ref: TerminalAST): void; protected ruleRef(ref: GrammarAST, arg: ActionAST): void; protected stringRef(ref: TerminalAST): void; protected enterAlternative(): void; protected exitAlternative(): void; protected enterElement(): void; protected exitElement(): void; protected enterBlockSet(): void; protected exitBlockSet(): void; protected exitSubrule(tree: GrammarAST): void; protected enterLexerAlternative(): void; protected exitLexerAlternative(): void; protected enterLexerElement(): void; protected exitLexerElement(): void; protected exitLexerSubrule(tree: GrammarAST): void; }