UNPKG

antlr-ng

Version:

Next generation ANTLR Tool

49 lines (48 loc) 1.25 kB
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); import { ClassFactory } from "../ClassFactory.js"; import { Grammar } from "./Grammar.js"; class LexerGrammar extends Grammar { static { __name(this, "LexerGrammar"); } /** The grammar from which this lexer grammar was derived (if implicit). */ implicitLexerOwner; /** DEFAULT_MODE rules are added first due to grammar syntax order. */ modes = /* @__PURE__ */ new Map(); defineRule(r) { if (!super.defineRule(r) || !r.mode) { return false; } let ruleList = this.modes.get(r.mode); if (!ruleList) { ruleList = []; this.modes.set(r.mode, ruleList); } ruleList.push(r); return true; } undefineRule(r) { if (!super.undefineRule(r) || !r.mode) { return false; } const ruleList = this.modes.get(r.mode); if (!ruleList) { return false; } const index = ruleList.indexOf(r); if (index === -1) { return false; } ruleList.splice(index, 1); return true; } static { ClassFactory.createLexerGrammar = (tool, ast) => { return new LexerGrammar(tool, ast); }; } } export { LexerGrammar };