UNPKG

antlr-ng

Version:

Next generation ANTLR Tool

52 lines (51 loc) 2.68 kB
import { GrammarTreeVisitor } from "../tree/walkers/GrammarTreeVisitor.js"; import { ActionAST } from "../tool/ast/ActionAST.js"; import { AltAST } from "../tool/ast/AltAST.js"; import { GrammarAST } from "../tool/ast/GrammarAST.js"; import { GrammarASTWithOptions } from "../tool/ast/GrammarASTWithOptions.js"; import { PredAST } from "../tool/ast/PredAST.js"; import { RuleAST } from "../tool/ast/RuleAST.js"; import { TerminalAST } from "../tool/ast/TerminalAST.js"; import { Grammar } from "../tool/Grammar.js"; import { Rule } from "../tool/Rule.js"; /** * Collects (create) rules, terminals, strings, actions, scopes etc... from AST side-effects: sets resolver field * of asts for actions and defines predicates via definePredicateInAlt(), collects actions and stores in alts. * TODO: remove side-effects! */ export declare class SymbolCollector extends GrammarTreeVisitor { /** which grammar are we checking */ g: Grammar; ruleRefs: GrammarAST[]; qualifiedRuleRefs: GrammarAST[]; terminals: GrammarAST[]; tokenIDRefs: GrammarAST[]; strings: Set<string>; tokensDefs: GrammarAST[]; channelDefs: GrammarAST[]; currentRule: Rule | null; /** Track action name node in @parser::members {...} or @members {...} */ readonly namedActions: GrammarAST[]; constructor(g: Grammar); process(ast: GrammarAST): void; globalNamedAction(scope: GrammarAST, id: GrammarAST, action: ActionAST): void; defineToken(id: GrammarAST): void; defineChannel(id: GrammarAST): void; discoverRule(rule: RuleAST, id: GrammarAST, modifiers: GrammarAST[], arg: ActionAST, returns: ActionAST, throws: GrammarAST, options: GrammarAST, locals: ActionAST, actions: GrammarAST[], block: GrammarAST): void; discoverLexerRule(rule: RuleAST, id: GrammarAST, modifiers: GrammarAST[], options: GrammarAST, block: GrammarAST): void; discoverOuterAlt(alt: AltAST): void; actionInAlt(action: ActionAST): void; sempredInAlt(pred: PredAST): void; ruleCatch(arg: GrammarAST, action: ActionAST): void; finallyAction(action: ActionAST): void; label(op: GrammarAST, id: GrammarAST, element: GrammarAST): void; stringRef(ref: TerminalAST): void; tokenRef(ref: TerminalAST): void; ruleRef(ref: GrammarAST, arg: ActionAST): void; grammarOption(_id: GrammarAST, valueAST: GrammarAST): void; ruleOption(_id: GrammarAST, valueAST: GrammarAST): void; blockOption(_id: GrammarAST, valueAST: GrammarAST): void; elementOption(t: GrammarASTWithOptions, id: GrammarAST, valueAST: GrammarAST): void; /** In case of option id={...}, set resolve in case they use $foo */ private setActionResolver; }