astexplorer.app
Version:
https://astexplorer.net with ES Modules support and Hot Reloading
1 lines • 755 kB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[34],{"./node_modules/chevrotain/lib_esm/src/api.js":function(module,__webpack_exports__,__webpack_require__){"use strict";eval('// ESM COMPAT FLAG\n__webpack_require__.r(__webpack_exports__);\n\n// EXPORTS\n__webpack_require__.d(__webpack_exports__, "VERSION", function() { return /* reexport */ VERSION; });\n__webpack_require__.d(__webpack_exports__, "Parser", function() { return /* reexport */ parser_Parser; });\n__webpack_require__.d(__webpack_exports__, "CstParser", function() { return /* reexport */ parser_CstParser; });\n__webpack_require__.d(__webpack_exports__, "EmbeddedActionsParser", function() { return /* reexport */ parser_EmbeddedActionsParser; });\n__webpack_require__.d(__webpack_exports__, "ParserDefinitionErrorType", function() { return /* reexport */ ParserDefinitionErrorType; });\n__webpack_require__.d(__webpack_exports__, "EMPTY_ALT", function() { return /* reexport */ EMPTY_ALT; });\n__webpack_require__.d(__webpack_exports__, "Lexer", function() { return /* reexport */ lexer_public_Lexer; });\n__webpack_require__.d(__webpack_exports__, "LexerDefinitionErrorType", function() { return /* reexport */ LexerDefinitionErrorType; });\n__webpack_require__.d(__webpack_exports__, "createToken", function() { return /* reexport */ createToken; });\n__webpack_require__.d(__webpack_exports__, "createTokenInstance", function() { return /* reexport */ createTokenInstance; });\n__webpack_require__.d(__webpack_exports__, "EOF", function() { return /* reexport */ EOF; });\n__webpack_require__.d(__webpack_exports__, "tokenLabel", function() { return /* reexport */ tokenLabel; });\n__webpack_require__.d(__webpack_exports__, "tokenMatcher", function() { return /* reexport */ tokens_public_tokenMatcher; });\n__webpack_require__.d(__webpack_exports__, "tokenName", function() { return /* reexport */ tokenName; });\n__webpack_require__.d(__webpack_exports__, "defaultGrammarResolverErrorProvider", function() { return /* reexport */ defaultGrammarResolverErrorProvider; });\n__webpack_require__.d(__webpack_exports__, "defaultGrammarValidatorErrorProvider", function() { return /* reexport */ defaultGrammarValidatorErrorProvider; });\n__webpack_require__.d(__webpack_exports__, "defaultParserErrorProvider", function() { return /* reexport */ defaultParserErrorProvider; });\n__webpack_require__.d(__webpack_exports__, "EarlyExitException", function() { return /* reexport */ EarlyExitException; });\n__webpack_require__.d(__webpack_exports__, "isRecognitionException", function() { return /* reexport */ isRecognitionException; });\n__webpack_require__.d(__webpack_exports__, "MismatchedTokenException", function() { return /* reexport */ MismatchedTokenException; });\n__webpack_require__.d(__webpack_exports__, "NotAllInputParsedException", function() { return /* reexport */ NotAllInputParsedException; });\n__webpack_require__.d(__webpack_exports__, "NoViableAltException", function() { return /* reexport */ NoViableAltException; });\n__webpack_require__.d(__webpack_exports__, "defaultLexerErrorProvider", function() { return /* reexport */ defaultLexerErrorProvider; });\n__webpack_require__.d(__webpack_exports__, "Alternation", function() { return /* reexport */ gast_public_Alternation; });\n__webpack_require__.d(__webpack_exports__, "Flat", function() { return /* reexport */ gast_public_Flat; });\n__webpack_require__.d(__webpack_exports__, "NonTerminal", function() { return /* reexport */ gast_public_NonTerminal; });\n__webpack_require__.d(__webpack_exports__, "Option", function() { return /* reexport */ gast_public_Option; });\n__webpack_require__.d(__webpack_exports__, "Repetition", function() { return /* reexport */ gast_public_Repetition; });\n__webpack_require__.d(__webpack_exports__, "RepetitionMandatory", function() { return /* reexport */ gast_public_RepetitionMandatory; });\n__webpack_require__.d(__webpack_exports__, "RepetitionMandatoryWithSeparator", function() { return /* reexport */ gast_public_RepetitionMandatoryWithSeparator; });\n__webpack_require__.d(__webpack_exports__, "RepetitionWithSeparator", function() { return /* reexport */ gast_public_RepetitionWithSeparator; });\n__webpack_require__.d(__webpack_exports__, "Rule", function() { return /* reexport */ gast_public_Rule; });\n__webpack_require__.d(__webpack_exports__, "Terminal", function() { return /* reexport */ gast_public_Terminal; });\n__webpack_require__.d(__webpack_exports__, "serializeGrammar", function() { return /* reexport */ serializeGrammar; });\n__webpack_require__.d(__webpack_exports__, "serializeProduction", function() { return /* reexport */ serializeProduction; });\n__webpack_require__.d(__webpack_exports__, "GAstVisitor", function() { return /* reexport */ gast_visitor_public_GAstVisitor; });\n__webpack_require__.d(__webpack_exports__, "assignOccurrenceIndices", function() { return /* reexport */ assignOccurrenceIndices; });\n__webpack_require__.d(__webpack_exports__, "resolveGrammar", function() { return /* reexport */ gast_resolver_public_resolveGrammar; });\n__webpack_require__.d(__webpack_exports__, "validateGrammar", function() { return /* reexport */ gast_resolver_public_validateGrammar; });\n__webpack_require__.d(__webpack_exports__, "clearCache", function() { return /* binding */ clearCache; });\n__webpack_require__.d(__webpack_exports__, "createSyntaxDiagramsCode", function() { return /* reexport */ createSyntaxDiagramsCode; });\n__webpack_require__.d(__webpack_exports__, "generateParserFactory", function() { return /* reexport */ generateParserFactory; });\n__webpack_require__.d(__webpack_exports__, "generateParserModule", function() { return /* reexport */ generateParserModule; });\n\n// CONCATENATED MODULE: ./node_modules/chevrotain/lib_esm/src/version.js\n// needs a separate module as this is required inside chevrotain productive code\n// and also in the entry point for webpack(api.ts).\n// A separate file avoids cyclic dependencies and webpack errors.\nvar VERSION = "6.5.0";\n//# sourceMappingURL=version.js.map\n// EXTERNAL MODULE: ./node_modules/chevrotain/lib_esm/src/utils/utils.js\nvar utils = __webpack_require__("./node_modules/chevrotain/lib_esm/src/utils/utils.js");\n\n// EXTERNAL MODULE: ./node_modules/regexp-to-ast/lib/regexp-to-ast.js\nvar regexp_to_ast = __webpack_require__("./node_modules/regexp-to-ast/lib/regexp-to-ast.js");\n\n// CONCATENATED MODULE: ./node_modules/chevrotain/lib_esm/src/scan/reg_exp_parser.js\n\nvar regExpAstCache = {};\nvar regExpParser = new regexp_to_ast["RegExpParser"]();\nfunction getRegExpAst(regExp) {\n var regExpStr = regExp.toString();\n if (regExpAstCache.hasOwnProperty(regExpStr)) {\n return regExpAstCache[regExpStr];\n }\n else {\n var regExpAst = regExpParser.pattern(regExpStr);\n regExpAstCache[regExpStr] = regExpAst;\n return regExpAst;\n }\n}\nfunction clearRegExpParserCache() {\n regExpAstCache = {};\n}\n//# sourceMappingURL=reg_exp_parser.js.map\n// CONCATENATED MODULE: ./node_modules/chevrotain/lib_esm/src/scan/reg_exp.js\nvar __extends = (undefined && undefined.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\n\n\n\n\nvar complementErrorMessage = "Complement Sets are not supported for first char optimization";\nvar failedOptimizationPrefixMsg = \'Unable to use "first char" lexer optimizations:\\n\';\nfunction getOptimizedStartCodesIndices(regExp, ensureOptimizations) {\n if (ensureOptimizations === void 0) { ensureOptimizations = false; }\n try {\n var ast = getRegExpAst(regExp);\n var firstChars = firstCharOptimizedIndices(ast.value, {}, ast.flags.ignoreCase);\n return firstChars;\n }\n catch (e) {\n /* istanbul ignore next */\n // Testing this relies on the regexp-to-ast library having a bug... */\n // TODO: only the else branch needs to be ignored, try to fix with newer prettier / tsc\n if (e.message === complementErrorMessage) {\n if (ensureOptimizations) {\n Object(utils["d" /* PRINT_WARNING */])("" + failedOptimizationPrefixMsg +\n ("\\tUnable to optimize: < " + regExp.toString() + " >\\n") +\n "\\tComplement Sets cannot be automatically optimized.\\n" +\n "\\tThis will disable the lexer\'s first char optimizations.\\n" +\n "\\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.");\n }\n }\n else {\n var msgSuffix = "";\n if (ensureOptimizations) {\n msgSuffix =\n "\\n\\tThis will disable the lexer\'s first char optimizations.\\n" +\n "\\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.";\n }\n Object(utils["c" /* PRINT_ERROR */])(failedOptimizationPrefixMsg + "\\n" +\n ("\\tFailed parsing: < " + regExp.toString() + " >\\n") +\n ("\\tUsing the regexp-to-ast library version: " + regexp_to_ast["VERSION"] + "\\n") +\n "\\tPlease open an issue at: https://github.com/bd82/regexp-to-ast/issues" +\n msgSuffix);\n }\n }\n return [];\n}\nfunction firstCharOptimizedIndices(ast, result, ignoreCase) {\n switch (ast.type) {\n case "Disjunction":\n for (var i = 0; i < ast.value.length; i++) {\n firstCharOptimizedIndices(ast.value[i], result, ignoreCase);\n }\n break;\n case "Alternative":\n var terms = ast.value;\n for (var i = 0; i < terms.length; i++) {\n var term = terms[i];\n // skip terms that cannot effect the first char results\n switch (term.type) {\n case "EndAnchor":\n // A group back reference cannot affect potential starting char.\n // because if a back reference is the first production than automatically\n // the group being referenced has had to come BEFORE so its codes have already been added\n case "GroupBackReference":\n // assertions do not affect potential starting codes\n case "Lookahead":\n case "NegativeLookahead":\n case "StartAnchor":\n case "WordBoundary":\n case "NonWordBoundary":\n continue;\n }\n var atom = term;\n switch (atom.type) {\n case "Character":\n addOptimizedIdxToResult(atom.value, result, ignoreCase);\n break;\n case "Set":\n if (atom.complement === true) {\n throw Error(complementErrorMessage);\n }\n Object(utils["u" /* forEach */])(atom.value, function (code) {\n if (typeof code === "number") {\n addOptimizedIdxToResult(code, result, ignoreCase);\n }\n else {\n // range\n var range = code;\n // cannot optimize when ignoreCase is\n if (ignoreCase === true) {\n for (var rangeCode = range.from; rangeCode <= range.to; rangeCode++) {\n addOptimizedIdxToResult(rangeCode, result, ignoreCase);\n }\n }\n // Optimization (2 orders of magnitude less work for very large ranges)\n else {\n // handle unoptimized values\n for (var rangeCode = range.from; rangeCode <= range.to &&\n rangeCode < minOptimizationVal; rangeCode++) {\n addOptimizedIdxToResult(rangeCode, result, ignoreCase);\n }\n // Less common charCode where we optimize for faster init time, by using larger "buckets"\n if (range.to >= minOptimizationVal) {\n var minUnOptVal = range.from >= minOptimizationVal\n ? range.from\n : minOptimizationVal;\n var maxUnOptVal = range.to;\n var minOptIdx = charCodeToOptimizedIndex(minUnOptVal);\n var maxOptIdx = charCodeToOptimizedIndex(maxUnOptVal);\n for (var currOptIdx = minOptIdx; currOptIdx <= maxOptIdx; currOptIdx++) {\n result[currOptIdx] = currOptIdx;\n }\n }\n }\n }\n });\n break;\n case "Group":\n firstCharOptimizedIndices(atom.value, result, ignoreCase);\n break;\n /* istanbul ignore next */\n default:\n throw Error("Non Exhaustive Match");\n }\n // reached a mandatory production, no more **start** codes can be found on this alternative\n var isOptionalQuantifier = atom.quantifier !== undefined &&\n atom.quantifier.atLeast === 0;\n if (\n // A group may be optional due to empty contents /(?:)/\n // or if everything inside it is optional /((a)?)/\n (atom.type === "Group" &&\n isWholeOptional(atom) === false) ||\n // If this term is not a group it may only be optional if it has an optional quantifier\n (atom.type !== "Group" && isOptionalQuantifier === false)) {\n break;\n }\n }\n break;\n /* istanbul ignore next */\n default:\n throw Error("non exhaustive match!");\n }\n // console.log(Object.keys(result).length)\n return Object(utils["U" /* values */])(result);\n}\nfunction addOptimizedIdxToResult(code, result, ignoreCase) {\n var optimizedCharIdx = charCodeToOptimizedIndex(code);\n result[optimizedCharIdx] = optimizedCharIdx;\n if (ignoreCase === true) {\n handleIgnoreCase(code, result);\n }\n}\nfunction handleIgnoreCase(code, result) {\n var char = String.fromCharCode(code);\n var upperChar = char.toUpperCase();\n /* istanbul ignore else */\n if (upperChar !== char) {\n var optimizedCharIdx = charCodeToOptimizedIndex(upperChar.charCodeAt(0));\n result[optimizedCharIdx] = optimizedCharIdx;\n }\n else {\n var lowerChar = char.toLowerCase();\n if (lowerChar !== char) {\n var optimizedCharIdx = charCodeToOptimizedIndex(lowerChar.charCodeAt(0));\n result[optimizedCharIdx] = optimizedCharIdx;\n }\n }\n}\nfunction findCode(setNode, targetCharCodes) {\n return Object(utils["q" /* find */])(setNode.value, function (codeOrRange) {\n if (typeof codeOrRange === "number") {\n return Object(utils["j" /* contains */])(targetCharCodes, codeOrRange);\n }\n else {\n // range\n var range_1 = codeOrRange;\n return (Object(utils["q" /* find */])(targetCharCodes, function (targetCode) {\n return range_1.from <= targetCode && targetCode <= range_1.to;\n }) !== undefined);\n }\n });\n}\nfunction isWholeOptional(ast) {\n if (ast.quantifier && ast.quantifier.atLeast === 0) {\n return true;\n }\n if (!ast.value) {\n return false;\n }\n return Object(utils["y" /* isArray */])(ast.value)\n ? Object(utils["o" /* every */])(ast.value, isWholeOptional)\n : isWholeOptional(ast.value);\n}\nvar reg_exp_CharCodeFinder = /** @class */ (function (_super) {\n __extends(CharCodeFinder, _super);\n function CharCodeFinder(targetCharCodes) {\n var _this = _super.call(this) || this;\n _this.targetCharCodes = targetCharCodes;\n _this.found = false;\n return _this;\n }\n CharCodeFinder.prototype.visitChildren = function (node) {\n // No need to keep looking...\n if (this.found === true) {\n return;\n }\n // switch lookaheads as they do not actually consume any characters thus\n // finding a charCode at lookahead context does not mean that regexp can actually contain it in a match.\n switch (node.type) {\n case "Lookahead":\n this.visitLookahead(node);\n return;\n case "NegativeLookahead":\n this.visitNegativeLookahead(node);\n return;\n }\n _super.prototype.visitChildren.call(this, node);\n };\n CharCodeFinder.prototype.visitCharacter = function (node) {\n if (Object(utils["j" /* contains */])(this.targetCharCodes, node.value)) {\n this.found = true;\n }\n };\n CharCodeFinder.prototype.visitSet = function (node) {\n if (node.complement) {\n if (findCode(node, this.targetCharCodes) === undefined) {\n this.found = true;\n }\n }\n else {\n if (findCode(node, this.targetCharCodes) !== undefined) {\n this.found = true;\n }\n }\n };\n return CharCodeFinder;\n}(regexp_to_ast["BaseRegExpVisitor"]));\nfunction canMatchCharCode(charCodes, pattern) {\n if (pattern instanceof RegExp) {\n var ast = getRegExpAst(pattern);\n var charCodeFinder = new reg_exp_CharCodeFinder(charCodes);\n charCodeFinder.visit(ast);\n return charCodeFinder.found;\n }\n else {\n return (Object(utils["q" /* find */])(pattern, function (char) {\n return Object(utils["j" /* contains */])(charCodes, char.charCodeAt(0));\n }) !== undefined);\n }\n}\n//# sourceMappingURL=reg_exp.js.map\n// CONCATENATED MODULE: ./node_modules/chevrotain/lib_esm/src/scan/lexer.js\nvar lexer_extends = (undefined && undefined.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\n\n\n\n\n\nvar PATTERN = "PATTERN";\nvar DEFAULT_MODE = "defaultMode";\nvar MODES = "modes";\nvar SUPPORT_STICKY = typeof new RegExp("(?:)").sticky === "boolean";\nfunction disableSticky() {\n SUPPORT_STICKY = false;\n}\nfunction enableSticky() {\n SUPPORT_STICKY = true;\n}\nfunction analyzeTokenTypes(tokenTypes, options) {\n options = Object(utils["k" /* defaults */])(options, {\n useSticky: SUPPORT_STICKY,\n debug: false,\n safeMode: false,\n positionTracking: "full",\n lineTerminatorCharacters: ["\\r", "\\n"],\n tracer: function (msg, action) { return action(); }\n });\n var tracer = options.tracer;\n tracer("initCharCodeToOptimizedIndexMap", function () {\n initCharCodeToOptimizedIndexMap();\n });\n var onlyRelevantTypes;\n tracer("Reject Lexer.NA", function () {\n onlyRelevantTypes = Object(utils["P" /* reject */])(tokenTypes, function (currType) {\n return currType[PATTERN] === lexer_public_Lexer.NA;\n });\n });\n var hasCustom = false;\n var allTransformedPatterns;\n tracer("Transform Patterns", function () {\n hasCustom = false;\n allTransformedPatterns = Object(utils["I" /* map */])(onlyRelevantTypes, function (currType) {\n var currPattern = currType[PATTERN];\n /* istanbul ignore else */\n if (Object(utils["D" /* isRegExp */])(currPattern)) {\n var regExpSource = currPattern.source;\n if (regExpSource.length === 1 &&\n // only these regExp meta characters which can appear in a length one regExp\n regExpSource !== "^" &&\n regExpSource !== "$" &&\n regExpSource !== ".") {\n return regExpSource;\n }\n else if (regExpSource.length === 2 &&\n regExpSource[0] === "\\\\" &&\n // not a meta character\n !Object(utils["j" /* contains */])([\n "d",\n "D",\n "s",\n "S",\n "t",\n "r",\n "n",\n "t",\n "0",\n "c",\n "b",\n "B",\n "f",\n "v",\n "w",\n "W"\n ], regExpSource[1])) {\n // escaped meta Characters: /\\+/ /\\[/\n // or redundant escaping: /\\a/\n // without the escaping "\\"\n return regExpSource[1];\n }\n else {\n return options.useSticky\n ? addStickyFlag(currPattern)\n : addStartOfInput(currPattern);\n }\n }\n else if (Object(utils["B" /* isFunction */])(currPattern)) {\n hasCustom = true;\n // CustomPatternMatcherFunc - custom patterns do not require any transformations, only wrapping in a RegExp Like object\n return { exec: currPattern };\n }\n else if (Object(utils["w" /* has */])(currPattern, "exec")) {\n hasCustom = true;\n // ICustomPattern\n return currPattern;\n }\n else if (typeof currPattern === "string") {\n if (currPattern.length === 1) {\n return currPattern;\n }\n else {\n var escapedRegExpString = currPattern.replace(/[\\\\^$.*+?()[\\]{}|]/g, "\\\\$&");\n var wrappedRegExp = new RegExp(escapedRegExpString);\n return options.useSticky\n ? addStickyFlag(wrappedRegExp)\n : addStartOfInput(wrappedRegExp);\n }\n }\n else {\n throw Error("non exhaustive match");\n }\n });\n });\n var patternIdxToType;\n var patternIdxToGroup;\n var patternIdxToLongerAltIdx;\n var patternIdxToPushMode;\n var patternIdxToPopMode;\n tracer("misc mapping", function () {\n patternIdxToType = Object(utils["I" /* map */])(onlyRelevantTypes, function (currType) { return currType.tokenTypeIdx; });\n patternIdxToGroup = Object(utils["I" /* map */])(onlyRelevantTypes, function (clazz) {\n var groupName = clazz.GROUP;\n /* istanbul ignore next */\n if (groupName === lexer_public_Lexer.SKIPPED) {\n return undefined;\n }\n else if (Object(utils["E" /* isString */])(groupName)) {\n return groupName;\n }\n else if (Object(utils["F" /* isUndefined */])(groupName)) {\n return false;\n }\n else {\n throw Error("non exhaustive match");\n }\n });\n patternIdxToLongerAltIdx = Object(utils["I" /* map */])(onlyRelevantTypes, function (clazz) {\n var longerAltType = clazz.LONGER_ALT;\n if (longerAltType) {\n var longerAltIdx = Object(utils["x" /* indexOf */])(onlyRelevantTypes, longerAltType);\n return longerAltIdx;\n }\n });\n patternIdxToPushMode = Object(utils["I" /* map */])(onlyRelevantTypes, function (clazz) { return clazz.PUSH_MODE; });\n patternIdxToPopMode = Object(utils["I" /* map */])(onlyRelevantTypes, function (clazz) {\n return Object(utils["w" /* has */])(clazz, "POP_MODE");\n });\n });\n var patternIdxToCanLineTerminator;\n tracer("Line Terminator Handling", function () {\n var lineTerminatorCharCodes = getCharCodes(options.lineTerminatorCharacters);\n patternIdxToCanLineTerminator = Object(utils["I" /* map */])(onlyRelevantTypes, function (tokType) { return false; });\n if (options.positionTracking !== "onlyOffset") {\n patternIdxToCanLineTerminator = Object(utils["I" /* map */])(onlyRelevantTypes, function (tokType) {\n if (Object(utils["w" /* has */])(tokType, "LINE_BREAKS")) {\n return tokType.LINE_BREAKS;\n }\n else {\n if (checkLineBreaksIssues(tokType, lineTerminatorCharCodes) === false) {\n return canMatchCharCode(lineTerminatorCharCodes, tokType.PATTERN);\n }\n }\n });\n }\n });\n var patternIdxToIsCustom;\n var patternIdxToShort;\n var emptyGroups;\n var patternIdxToConfig;\n tracer("Misc Mapping #2", function () {\n patternIdxToIsCustom = Object(utils["I" /* map */])(onlyRelevantTypes, isCustomPattern);\n patternIdxToShort = Object(utils["I" /* map */])(allTransformedPatterns, isShortPattern);\n emptyGroups = Object(utils["O" /* reduce */])(onlyRelevantTypes, function (acc, clazz) {\n var groupName = clazz.GROUP;\n if (Object(utils["E" /* isString */])(groupName) && !(groupName === lexer_public_Lexer.SKIPPED)) {\n acc[groupName] = [];\n }\n return acc;\n }, {});\n patternIdxToConfig = Object(utils["I" /* map */])(allTransformedPatterns, function (x, idx) {\n return {\n pattern: allTransformedPatterns[idx],\n longerAlt: patternIdxToLongerAltIdx[idx],\n canLineTerminator: patternIdxToCanLineTerminator[idx],\n isCustom: patternIdxToIsCustom[idx],\n short: patternIdxToShort[idx],\n group: patternIdxToGroup[idx],\n push: patternIdxToPushMode[idx],\n pop: patternIdxToPopMode[idx],\n tokenTypeIdx: patternIdxToType[idx],\n tokenType: onlyRelevantTypes[idx]\n };\n });\n });\n var canBeOptimized = true;\n var charCodeToPatternIdxToConfig = [];\n if (!options.safeMode) {\n tracer("First Char Optimization", function () {\n charCodeToPatternIdxToConfig = Object(utils["O" /* reduce */])(onlyRelevantTypes, function (result, currTokType, idx) {\n if (typeof currTokType.PATTERN === "string") {\n var charCode = currTokType.PATTERN.charCodeAt(0);\n var optimizedIdx = charCodeToOptimizedIndex(charCode);\n addToMapOfArrays(result, optimizedIdx, patternIdxToConfig[idx]);\n }\n else if (Object(utils["y" /* isArray */])(currTokType.START_CHARS_HINT)) {\n var lastOptimizedIdx_1;\n Object(utils["u" /* forEach */])(currTokType.START_CHARS_HINT, function (charOrInt) {\n var charCode = typeof charOrInt === "string"\n ? charOrInt.charCodeAt(0)\n : charOrInt;\n var currOptimizedIdx = charCodeToOptimizedIndex(charCode);\n // Avoid adding the config multiple times\n if (lastOptimizedIdx_1 !== currOptimizedIdx) {\n lastOptimizedIdx_1 = currOptimizedIdx;\n addToMapOfArrays(result, currOptimizedIdx, patternIdxToConfig[idx]);\n }\n });\n }\n else if (Object(utils["D" /* isRegExp */])(currTokType.PATTERN)) {\n if (currTokType.PATTERN.unicode) {\n canBeOptimized = false;\n if (options.ensureOptimizations) {\n Object(utils["c" /* PRINT_ERROR */])("" + failedOptimizationPrefixMsg +\n ("\\tUnable to analyze < " + currTokType.PATTERN.toString() + " > pattern.\\n") +\n "\\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\\n" +\n "\\tThis will disable the lexer\'s first char optimizations.\\n" +\n "\\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE");\n }\n }\n else {\n var optimizedCodes = getOptimizedStartCodesIndices(currTokType.PATTERN, options.ensureOptimizations);\n /* istanbul ignore if */\n // start code will only be empty given an empty regExp or failure of regexp-to-ast library\n // the first should be a different validation and the second cannot be tested.\n if (Object(utils["A" /* isEmpty */])(optimizedCodes)) {\n // we cannot understand what codes may start possible matches\n // The optimization correctness requires knowing start codes for ALL patterns.\n // Not actually sure this is an error, no debug message\n canBeOptimized = false;\n }\n Object(utils["u" /* forEach */])(optimizedCodes, function (code) {\n addToMapOfArrays(result, code, patternIdxToConfig[idx]);\n });\n }\n }\n else {\n if (options.ensureOptimizations) {\n Object(utils["c" /* PRINT_ERROR */])("" + failedOptimizationPrefixMsg +\n ("\\tTokenType: <" + currTokType.name + "> is using a custom token pattern without providing <start_chars_hint> parameter.\\n") +\n "\\tThis will disable the lexer\'s first char optimizations.\\n" +\n "\\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE");\n }\n canBeOptimized = false;\n }\n return result;\n }, []);\n });\n }\n tracer("ArrayPacking", function () {\n charCodeToPatternIdxToConfig = Object(utils["L" /* packArray */])(charCodeToPatternIdxToConfig);\n });\n return {\n emptyGroups: emptyGroups,\n patternIdxToConfig: patternIdxToConfig,\n charCodeToPatternIdxToConfig: charCodeToPatternIdxToConfig,\n hasCustom: hasCustom,\n canBeOptimized: canBeOptimized\n };\n}\nfunction validatePatterns(tokenTypes, validModesNames) {\n var errors = [];\n var missingResult = findMissingPatterns(tokenTypes);\n errors = errors.concat(missingResult.errors);\n var invalidResult = findInvalidPatterns(missingResult.valid);\n var validTokenTypes = invalidResult.valid;\n errors = errors.concat(invalidResult.errors);\n errors = errors.concat(validateRegExpPattern(validTokenTypes));\n errors = errors.concat(findInvalidGroupType(validTokenTypes));\n errors = errors.concat(findModesThatDoNotExist(validTokenTypes, validModesNames));\n errors = errors.concat(findUnreachablePatterns(validTokenTypes));\n return errors;\n}\nfunction validateRegExpPattern(tokenTypes) {\n var errors = [];\n var withRegExpPatterns = Object(utils["p" /* filter */])(tokenTypes, function (currTokType) {\n return Object(utils["D" /* isRegExp */])(currTokType[PATTERN]);\n });\n errors = errors.concat(findEndOfInputAnchor(withRegExpPatterns));\n errors = errors.concat(findStartOfInputAnchor(withRegExpPatterns));\n errors = errors.concat(findUnsupportedFlags(withRegExpPatterns));\n errors = errors.concat(findDuplicatePatterns(withRegExpPatterns));\n errors = errors.concat(findEmptyMatchRegExps(withRegExpPatterns));\n return errors;\n}\nfunction findMissingPatterns(tokenTypes) {\n var tokenTypesWithMissingPattern = Object(utils["p" /* filter */])(tokenTypes, function (currType) {\n return !Object(utils["w" /* has */])(currType, PATTERN);\n });\n var errors = Object(utils["I" /* map */])(tokenTypesWithMissingPattern, function (currType) {\n return {\n message: "Token Type: ->" +\n currType.name +\n "<- missing static \'PATTERN\' property",\n type: LexerDefinitionErrorType.MISSING_PATTERN,\n tokenTypes: [currType]\n };\n });\n var valid = Object(utils["l" /* difference */])(tokenTypes, tokenTypesWithMissingPattern);\n return { errors: errors, valid: valid };\n}\nfunction findInvalidPatterns(tokenTypes) {\n var tokenTypesWithInvalidPattern = Object(utils["p" /* filter */])(tokenTypes, function (currType) {\n var pattern = currType[PATTERN];\n return (!Object(utils["D" /* isRegExp */])(pattern) &&\n !Object(utils["B" /* isFunction */])(pattern) &&\n !Object(utils["w" /* has */])(pattern, "exec") &&\n !Object(utils["E" /* isString */])(pattern));\n });\n var errors = Object(utils["I" /* map */])(tokenTypesWithInvalidPattern, function (currType) {\n return {\n message: "Token Type: ->" +\n currType.name +\n "<- static \'PATTERN\' can only be a RegExp, a" +\n " Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",\n type: LexerDefinitionErrorType.INVALID_PATTERN,\n tokenTypes: [currType]\n };\n });\n var valid = Object(utils["l" /* difference */])(tokenTypes, tokenTypesWithInvalidPattern);\n return { errors: errors, valid: valid };\n}\nvar end_of_input = /[^\\\\][\\$]/;\nfunction findEndOfInputAnchor(tokenTypes) {\n var EndAnchorFinder = /** @class */ (function (_super) {\n lexer_extends(EndAnchorFinder, _super);\n function EndAnchorFinder() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.found = false;\n return _this;\n }\n EndAnchorFinder.prototype.visitEndAnchor = function (node) {\n this.found = true;\n };\n return EndAnchorFinder;\n }(regexp_to_ast["BaseRegExpVisitor"]));\n var invalidRegex = Object(utils["p" /* filter */])(tokenTypes, function (currType) {\n var pattern = currType[PATTERN];\n try {\n var regexpAst = getRegExpAst(pattern);\n var endAnchorVisitor = new EndAnchorFinder();\n endAnchorVisitor.visit(regexpAst);\n return endAnchorVisitor.found;\n }\n catch (e) {\n // old behavior in case of runtime exceptions with regexp-to-ast.\n /* istanbul ignore next - cannot ensure an error in regexp-to-ast*/\n return end_of_input.test(pattern.source);\n }\n });\n var errors = Object(utils["I" /* map */])(invalidRegex, function (currType) {\n return {\n message: "Unexpected RegExp Anchor Error:\\n" +\n "\\tToken Type: ->" +\n currType.name +\n "<- static \'PATTERN\' cannot contain end of input anchor \'$\'\\n" +\n "\\tSee sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#ANCHORS" +\n "\\tfor details.",\n type: LexerDefinitionErrorType.EOI_ANCHOR_FOUND,\n tokenTypes: [currType]\n };\n });\n return errors;\n}\nfunction findEmptyMatchRegExps(tokenTypes) {\n var matchesEmptyString = Object(utils["p" /* filter */])(tokenTypes, function (currType) {\n var pattern = currType[PATTERN];\n return pattern.test("");\n });\n var errors = Object(utils["I" /* map */])(matchesEmptyString, function (currType) {\n return {\n message: "Token Type: ->" +\n currType.name +\n "<- static \'PATTERN\' must not match an empty string",\n type: LexerDefinitionErrorType.EMPTY_MATCH_PATTERN,\n tokenTypes: [currType]\n };\n });\n return errors;\n}\nvar start_of_input = /[^\\\\[][\\^]|^\\^/;\nfunction findStartOfInputAnchor(tokenTypes) {\n var StartAnchorFinder = /** @class */ (function (_super) {\n lexer_extends(StartAnchorFinder, _super);\n function StartAnchorFinder() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n _this.found = false;\n return _this;\n }\n StartAnchorFinder.prototype.visitStartAnchor = function (node) {\n this.found = true;\n };\n return StartAnchorFinder;\n }(regexp_to_ast["BaseRegExpVisitor"]));\n var invalidRegex = Object(utils["p" /* filter */])(tokenTypes, function (currType) {\n var pattern = currType[PATTERN];\n try {\n var regexpAst = getRegExpAst(pattern);\n var startAnchorVisitor = new StartAnchorFinder();\n startAnchorVisitor.visit(regexpAst);\n return startAnchorVisitor.found;\n }\n catch (e) {\n // old behavior in case of runtime exceptions with regexp-to-ast.\n /* istanbul ignore next - cannot ensure an error in regexp-to-ast*/\n return start_of_input.test(pattern.source);\n }\n });\n var errors = Object(utils["I" /* map */])(invalidRegex, function (currType) {\n return {\n message: "Unexpected RegExp Anchor Error:\\n" +\n "\\tToken Type: ->" +\n currType.name +\n "<- static \'PATTERN\' cannot contain start of input anchor \'^\'\\n" +\n "\\tSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#ANCHORS" +\n "\\tfor details.",\n type: LexerDefinitionErrorType.SOI_ANCHOR_FOUND,\n tokenTypes: [currType]\n };\n });\n return errors;\n}\nfunction findUnsupportedFlags(tokenTypes) {\n var invalidFlags = Object(utils["p" /* filter */])(tokenTypes, function (currType) {\n var pattern = currType[PATTERN];\n return (pattern instanceof RegExp && (pattern.multiline || pattern.global));\n });\n var errors = Object(utils["I" /* map */])(invalidFlags, function (currType) {\n return {\n message: "Token Type: ->" +\n currType.name +\n "<- static \'PATTERN\' may NOT contain global(\'g\') or multiline(\'m\')",\n type: LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,\n tokenTypes: [currType]\n };\n });\n return errors;\n}\n// This can only test for identical duplicate RegExps, not semantically equivalent ones.\nfunction findDuplicatePatterns(tokenTypes) {\n var found = [];\n var identicalPatterns = Object(utils["I" /* map */])(tokenTypes, function (outerType) {\n return Object(utils["O" /* reduce */])(tokenTypes, function (result, innerType) {\n if (outerType.PATTERN.source === innerType.PATTERN.source &&\n !Object(utils["j" /* contains */])(found, innerType) &&\n innerType.PATTERN !== lexer_public_Lexer.NA) {\n // this avoids duplicates in the result, each Token Type may only appear in one "set"\n // in essence we are creating Equivalence classes on equality relation.\n found.push(innerType);\n result.push(innerType);\n return result;\n }\n return result;\n }, []);\n });\n identicalPatterns = Object(utils["i" /* compact */])(identicalPatterns);\n var duplicatePatterns = Object(utils["p" /* filter */])(identicalPatterns, function (currIdenticalSet) {\n return currIdenticalSet.length > 1;\n });\n var errors = Object(utils["I" /* map */])(duplicatePatterns, function (setOfIdentical) {\n var tokenTypeNames = Object(utils["I" /* map */])(setOfIdentical, function (currType) {\n return currType.name;\n });\n var dupPatternSrc = Object(utils["s" /* first */])(setOfIdentical).PATTERN;\n return {\n message: "The same RegExp pattern ->" + dupPatternSrc + "<-" +\n ("has been used in all of the following Token Types: " + tokenTypeNames.join(", ") + " <-"),\n type: LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,\n tokenTypes: setOfIdentical\n };\n });\n return errors;\n}\nfunction findInvalidGroupType(tokenTypes) {\n var invalidTypes = Object(utils["p" /* filter */])(tokenTypes, function (clazz) {\n if (!Object(utils["w" /* has */])(clazz, "GROUP")) {\n return false;\n }\n var group = clazz.GROUP;\n return group !== lexer_public_Lexer.SKIPPED && group !== lexer_public_Lexer.NA && !Object(utils["E" /* isString */])(group);\n });\n var errors = Object(utils["I" /* map */])(invalidTypes, function (currType) {\n return {\n message: "Token Type: ->" +\n currType.name +\n "<- static \'GROUP\' can only be Lexer.SKIPPED/Lexer.NA/A String",\n type: LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,\n tokenTypes: [currType]\n };\n });\n return errors;\n}\nfunction findModesThatDoNotExist(tokenTypes, validModes) {\n var invalidModes = Object(utils["p" /* filter */])(tokenTypes, function (clazz) {\n return (clazz.PUSH_MODE !== undefined &&\n !Object(utils["j" /* contains */])(validModes, clazz.PUSH_MODE));\n });\n var errors = Object(utils["I" /* map */])(invalidModes, function (tokType) {\n var msg = "Token Type: ->" + tokType.name + "<- static \'PUSH_MODE\' value cannot refer to a Lexer Mode ->" + tokType.PUSH_MODE + "<-" +\n "which does not exist";\n return {\n message: msg,\n type: LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST,\n tokenTypes: [tokType]\n };\n });\n return errors;\n}\nfunction findUnreachablePatterns(tokenTypes) {\n var errors = [];\n var canBeTested = Object(utils["O" /* reduce */])(tokenTypes, function (result, tokType, idx) {\n var pattern = tokType.PATTERN;\n if (pattern === lexer_public_Lexer.NA) {\n return result;\n }\n // a more comprehensive validation for all forms of regExps would require\n // deeper regExp analysis capabilities\n if (Object(utils["E" /* isString */])(pattern)) {\n result.push({ str: pattern, idx: idx, tokenType: tokType });\n }\n else if (Object(utils["D" /* isRegExp */])(pattern) && noMetaChar(pattern)) {\n result.push({ str: pattern.source, idx: idx, tokenType: tokType });\n }\n return result;\n }, []);\n Object(utils["u" /* forEach */])(tokenTypes, function (tokType, testIdx) {\n Object(utils["u" /* forEach */])(canBeTested, function (_a) {\n var str = _a.str, idx = _a.idx, tokenType = _a.tokenType;\n if (testIdx < idx && testTokenType(str, tokType.PATTERN)) {\n var msg = "Token: ->" + tokenType.name + "<- can never be matched.\\n" +\n ("Because it appears AFTER the Token Type ->" + tokType.name + "<-") +\n "in the lexer\'s definition.\\n" +\n "See https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#UNREACHABLE";\n errors.push({\n message: msg,\n type: LexerDefinitionErrorType.UNREACHABLE_PATTERN,\n tokenTypes: [tokType, tokenType]\n });\n }\n });\n });\n return errors;\n}\nfunction testTokenType(str, pattern) {\n /* istanbul ignore else */\n if (Object(utils["D" /* isRegExp */])(pattern)) {\n var regExpArray = pattern.exec(str);\n return regExpArray !== null && regExpArray.index === 0;\n }\n else if (Object(utils["B" /* isFunction */])(pattern)) {\n // maintain the API of custom patterns\n return pattern(str, 0, [], {});\n }\n else if (Object(utils["w" /* has */])(pattern, "exec")) {\n // maintain the API of custom patterns\n return pattern.exec(str, 0, [], {});\n }\n else if (typeof pattern === "string") {\n return pattern === str;\n }\n else {\n throw Error("non exhaustive match");\n }\n}\nfunction noMetaChar(regExp) {\n //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp\n var metaChars = [\n ".",\n "\\\\",\n "[",\n "]",\n "|",\n "^",\n "$",\n "(",\n ")",\n "?",\n "*",\n "+",\n "{"\n ];\n return (Object(utils["q" /* find */])(metaChars, function (char) { return regExp.source.indexOf(char) !== -1; }) ===\n undefined);\n}\nfunction addStartOfInput(pattern) {\n var flags = pattern.ignoreCase ? "i" : "";\n // always wrapping in a none capturing group preceded by \'^\' to make sure matching can only work on start of input.\n // duplicate/redundant start of input markers have no meaning (/^^^^A/ === /^A/)\n return new RegExp("^(?:" + pattern.source + ")", flags);\n}\nfunction addStickyFlag(pattern) {\n var flags = pattern.ignoreCase ? "iy" : "y";\n // always wrapping in a none capturing group preceded by \'^\' to make sure matching can only work on start of input.\n // duplicate/redundant start of input markers have no meaning (/^^^^A/ === /^A/)\n return new RegExp("" + pattern.source, flags);\n}\nfunction performRuntimeChecks(lexerDefinition, trackLines, lineTerminatorCharacters) {\n var errors = [];\n // some run time checks to help the end users.\n if (!Object(utils["w" /* has */])(lexerDefinition, DEFAULT_MODE)) {\n errors.push({\n message: "A MultiMode Lexer cannot be initialized without a <" +\n DEFAULT_MODE +\n "> property in its definition\\n",\n type: LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE\n });\n }\n if (!Object(utils["w" /* has */])(lexerDefinition, MODES)) {\n errors.push({\n message: "A MultiMode Lexer cannot be initialized without a <" +\n MODES +\n "> property in its definition\\n",\n type: LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY\n });\n }\n if (Object(utils["w" /* has */])(lexerDefinition, MODES) &&\n Object(utils["w" /* has */])(lexerDefinition, DEFAULT_MODE) &&\n !Object(utils["w" /* has */])(lexerDefinition.modes, lexerDefinition.defaultMode)) {\n errors.push({\n message: "A MultiMode Lexer cannot be initialized with a " + DEFAULT_MODE + ": <" + lexerDefinition.defaultMode + ">" +\n "which does not exist\\n",\n type: LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST\n });\n }\n if (Object(utils["w" /* has */])(lexerDefinition, MODES)) {\n Object(utils["u" /* forEach */])(lexerDefinition.modes, function (currModeValue, currModeName) {\n Object(utils["u" /* forEach */])(currModeValue, function (currTokType, currIdx) {\n if (Object(utils["F" /* isUndefined */])(currTokType)) {\n errors.push({\n message: "A Lexer cannot be initialized using an undefined Token Type. Mode:" +\n ("<" + currModeName + "> at index: <" + currIdx + ">\\n"),\n type: LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED\n });\n }\n });\n });\n }\n return errors;\n}\nfunction performWarningRuntimeChecks(lexerDefinition, trackLines, lineTerminatorC