@oseo/compiler 0.1.0-canary.0 → 0.1.0-canary.370
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -165
- package/dist/agent-programs.d.ts.map +1 -1
- package/dist/agent-programs.js.map +1 -1
- package/dist/agent-templates.d.ts.map +1 -1
- package/dist/agent-templates.js.map +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js.map +1 -1
- package/dist/fragments.d.ts.map +1 -1
- package/dist/fragments.js.map +1 -1
- package/dist/hir-build.d.ts.map +1 -1
- package/dist/hir-build.js.map +1 -1
- package/dist/hir-print.d.ts.map +1 -1
- package/dist/hir-print.js.map +1 -1
- package/dist/hir.d.ts.map +1 -1
- package/dist/hir.js.map +1 -1
- package/dist/host-scripts.d.ts.map +1 -1
- package/dist/host-scripts.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mir-build.d.ts.map +1 -1
- package/dist/mir-build.js.map +1 -1
- package/dist/mir-print.d.ts.map +1 -1
- package/dist/mir-print.js.map +1 -1
- package/dist/mir-specialize.d.ts.map +1 -1
- package/dist/mir-specialize.js.map +1 -1
- package/dist/mir.d.ts.map +1 -1
- package/dist/module-builtin.d.ts.map +1 -1
- package/dist/module-builtin.js.map +1 -1
- package/dist/module-compile.d.ts.map +1 -1
- package/dist/module-compile.js.map +1 -1
- package/dist/module-json.d.ts.map +1 -1
- package/dist/module-json.js.map +1 -1
- package/dist/modules.d.ts.map +1 -1
- package/dist/modules.js.map +1 -1
- package/dist/native-fragments.d.ts.map +1 -1
- package/dist/native-fragments.js.map +1 -1
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/regexp-execute.d.ts.map +1 -1
- package/dist/regexp-execute.js.map +1 -1
- package/dist/regexp-matcher.d.ts.map +1 -1
- package/dist/regexp-matcher.js.map +1 -1
- package/dist/regexp-parse.d.ts.map +1 -1
- package/dist/regexp-parse.js.map +1 -1
- package/dist/regexp-print.d.ts.map +1 -1
- package/dist/regexp-print.js.map +1 -1
- package/dist/regexp.d.ts.map +1 -1
- package/dist/regexp.js.map +1 -1
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js.map +1 -1
- package/dist/syntax.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/regexp-parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp-parse.js","names":[],"sources":["../src/regexp-parse.ts"],"sourcesContent":["import {\n defaultRegExpPatternLimits,\n regExpUnicodeMode,\n type RegExpAlternative,\n type RegExpAtom,\n type RegExpCapture,\n type RegExpCharacter,\n type RegExpCharacterClass,\n type RegExpClassSetOperand,\n type RegExpClassStringDisjunction,\n type RegExpClassEscape,\n type RegExpClassEscapeSet,\n type RegExpClassItem,\n type RegExpDisjunction,\n type RegExpErrorKind,\n type RegExpErrorSection,\n type RegExpExtensionPoint,\n type RegExpFlags,\n type RegExpLookaround,\n type RegExpModifierFlag,\n type RegExpPattern,\n type RegExpPatternError,\n type RegExpPatternExtensions,\n type RegExpPatternInput,\n type RegExpPatternLimits,\n type RegExpPatternOptions,\n type RegExpPatternResult,\n type RegExpQuantifier,\n type RegExpSpan,\n type RegExpTerm,\n type RegExpUnicodePropertyEscape,\n type RegExpUnicodeClassSet,\n} from \"./regexp.ts\";\nimport type { RegExpLiteralSyntax } from \"./syntax.ts\";\n\nfunction includePropertiesWhen<const Properties extends object>(\n properties: () => Properties | undefined,\n): Properties | { [Key in keyof Properties]?: never } {\n return properties() ?? {};\n}\n\n/** Characters the grammar reserves, which a pattern character excludes. */\nconst syntaxCharacters = new Set(\"^$\\\\.*+?()[]{}|\");\n\n/** The five ControlEscape spellings and the code points they name. */\nconst controlEscapes = new Map<string, number>([\n [\"f\", 0x0c],\n [\"n\", 0x0a],\n [\"r\", 0x0d],\n [\"t\", 0x09],\n [\"v\", 0x0b],\n]);\n\n/** Modifier flags one inline modifier group may enable or disable. */\nconst modifierFlags = new Set<string>([\"i\", \"m\", \"s\"]);\n\n/** Binary properties of strings admitted only by positive `v` escapes. */\nconst unicodeStringProperties = new Set<string>([\n \"Basic_Emoji\",\n \"Emoji_Keycap_Sequence\",\n \"RGI_Emoji\",\n \"RGI_Emoji_Flag_Sequence\",\n \"RGI_Emoji_Modifier_Sequence\",\n \"RGI_Emoji_Tag_Sequence\",\n \"RGI_Emoji_ZWJ_Sequence\",\n]);\n\n/** Characters that must be escaped inside a Unicode class set. */\nconst classSetSyntaxCharacters = new Set<string>(\"(){}[/-|\");\n\n/** Punctuators reserved when two equal copies occur in a class set. */\nconst classSetReservedDoublePunctuators = new Set<string>(\n \"!#$%&*+,.:;<=>?@^`~\",\n);\n\nfunction readClassSetCharacterEscape(state: ParseState, start: number): number {\n const character = at(state, 0);\n if (\n character != null &&\n ((state.unicodeMode && character === \"-\") ||\n (state.flags.unicodeSets &&\n classSetReservedDoublePunctuators.has(character)))\n ) {\n state.index += 1;\n return character.codePointAt(0) ?? 0;\n }\n return readCharacterEscape(state, start, true);\n}\n\nconst noExtensions: RegExpPatternExtensions = { admitted: [] };\n\n/**\n * One rejected construct, thrown so a deep production reports its own\n * location without every caller forwarding a failure value.\n */\nclass PatternFailure extends Error {\n readonly error: RegExpPatternError;\n\n constructor(error: RegExpPatternError) {\n super(error.message);\n this.error = error;\n }\n}\n\n/**\n * Where one alternative sits in the enclosing disjunctions.\n *\n * Two groups with one name are admitted only when some enclosing\n * disjunction places them in different alternatives, so each named group\n * retains the alternative it was parsed in.\n */\ninterface AlternativePath {\n readonly alternative: number;\n readonly disjunction: number;\n}\n\ninterface NamedGroupRecord {\n readonly name: string;\n readonly path: readonly AlternativePath[];\n readonly span: RegExpSpan;\n}\n\ninterface BackreferenceRecord {\n readonly index: number;\n readonly span: RegExpSpan;\n}\n\ninterface NamedReferenceRecord {\n readonly name: string;\n readonly span: RegExpSpan;\n}\n\ninterface ParseState {\n /**\n * Whether this parse follows Annex B's pattern grammar: the caller left\n * it on and the flag set has neither `u` nor `v`.\n */\n readonly annexB: boolean;\n readonly backreferences: BackreferenceRecord[];\n /**\n * The left-capturing parentheses in the whole pattern text, which\n * Annex B compares a decimal escape against before it has parsed the\n * groups the escape may name. Zero outside Annex B, where validation\n * decides every reference after the parse.\n */\n readonly captureCount: number;\n readonly captures: RegExpCapture[];\n readonly extensions: RegExpPatternExtensions;\n readonly flags: RegExpFlags;\n /**\n * Whether the pattern text declares a group name.\n *\n * The grammar sets its named-reference parameter exactly when the\n * pattern holds a GroupSpecifier, and Annex B reads `\\k` as an identity\n * escape only without one. A reference can precede the declaration that\n * decides this, so the whole text answers it once before parsing rather\n * than each reference rescanning what it cannot see yet.\n */\n readonly groupNameDeclared: boolean;\n readonly limits: RegExpPatternLimits;\n readonly namedGroups: NamedGroupRecord[];\n /**\n * One index list per referenced name, shared by every node that names\n * it. Validation resolves each list once, so a pattern with many\n * references to one name holds one list rather than a copy per node.\n */\n readonly namedReferenceIndices: Map<string, number[]>;\n readonly namedReferences: NamedReferenceRecord[];\n readonly path: AlternativePath[];\n readonly source: string;\n readonly unicodeMode: boolean;\n depth: number;\n disjunctionCount: number;\n index: number;\n}\n\nfunction span(start: number, end: number): RegExpSpan {\n return { end, start };\n}\n\nfunction fail(\n kind: RegExpErrorKind,\n message: string,\n location: RegExpSpan,\n section: RegExpErrorSection = \"pattern\",\n): never {\n throw new PatternFailure({ kind, message, section, span: location });\n}\n\n/**\n * Describe a construct that only Annex B admits, for a parse that reached\n * it without Annex B's grammar.\n *\n * Under `u` or `v` Annex B never applied, so the rejection is the early\n * error the edition itself requires and reports as invalid text. Without\n * them the text is one a web browser accepts, and only a caller that asked\n * for the core grammar alone gets here, so the rejection names Annex B as\n * an `unsupported` construct rather than as a defect.\n */\nfunction annexBMessage(subject: string): string {\n const tail = \"is admitted only by Annex B, which this parse excludes.\";\n return `${subject} ${tail}`;\n}\n\nfunction annexBError(\n state: ParseState,\n invalidMessage: string,\n subject: string,\n location: RegExpSpan,\n): RegExpPatternError {\n return state.unicodeMode\n ? {\n kind: \"invalid\",\n message: invalidMessage,\n section: \"pattern\",\n span: location,\n }\n : {\n kind: \"unsupported\",\n message: annexBMessage(subject),\n section: \"pattern\",\n span: location,\n };\n}\n\n/** Reject a construct that only Annex B admits, keeping its span. */\nfunction refuseAnnexB(\n state: ParseState,\n invalidMessage: string,\n subject: string,\n location: RegExpSpan,\n): never {\n throw new PatternFailure(\n annexBError(state, invalidMessage, subject, location),\n );\n}\n\nfunction admits(state: ParseState, point: RegExpExtensionPoint): boolean {\n return state.extensions.admitted.includes(point);\n}\n\nfunction at(state: ParseState, offset: number): string | undefined {\n return state.source[state.index + offset];\n}\n\nfunction done(state: ParseState): boolean {\n return state.index >= state.source.length;\n}\n\nfunction eat(state: ParseState, text: string): boolean {\n if (!state.source.startsWith(text, state.index)) return false;\n state.index += text.length;\n return true;\n}\n\n/**\n * Read one source character.\n *\n * A pattern is a sequence of code points under `u` or `v` and a sequence\n * of UTF-16 code units otherwise, which is the only place the flag set\n * changes how text is consumed rather than what it means.\n */\nfunction readCharacter(state: ParseState): RegExpCharacter {\n const start = state.index;\n const unit = state.source.charCodeAt(start);\n const value = state.unicodeMode\n ? (state.source.codePointAt(start) ?? 0)\n : Number.isNaN(unit)\n ? 0\n : unit;\n state.index += value > 0xffff ? 2 : 1;\n return { kind: \"character\", span: span(start, state.index), value };\n}\n\nfunction isDecimalDigit(character: string | undefined): boolean {\n return character != null && character >= \"0\" && character <= \"9\";\n}\n\nfunction isHexDigit(character: string | undefined): boolean {\n if (character == null) return false;\n return (\n (character >= \"0\" && character <= \"9\") ||\n (character >= \"a\" && character <= \"f\") ||\n (character >= \"A\" && character <= \"F\")\n );\n}\n\nfunction readDecimalDigits(state: ParseState): string {\n const start = state.index;\n while (isDecimalDigit(at(state, 0))) state.index += 1;\n return state.source.slice(start, state.index);\n}\n\n/**\n * Whether one code point has the Unicode `ID_Start` or `ID_Continue`\n * property.\n *\n * The compiler core links no Unicode data, so ASCII is decided here and\n * anything else is delegated to the caller. Without a classifier a\n * non-ASCII code point is refused rather than guessed, which keeps an\n * unadmitted name out of the accepted grammar instead of admitting one\n * whose validity was never checked. The two properties are exactly what\n * the grammar names: the `$`, `_`, and zero-width joiner allowances of an\n * identifier belong to the caller of this predicate, not to it.\n */\nfunction identifierProperty(\n state: ParseState,\n codePoint: number,\n position: \"continue\" | \"start\",\n subject: string,\n location: RegExpSpan,\n): boolean {\n if (codePoint < 0x80) {\n const character = String.fromCharCode(codePoint);\n if (character >= \"a\" && character <= \"z\") return true;\n if (character >= \"A\" && character <= \"Z\") return true;\n if (position === \"start\") return false;\n return (character >= \"0\" && character <= \"9\") || character === \"_\";\n }\n const classify =\n position === \"start\"\n ? state.extensions.identifierStart\n : state.extensions.identifierPart;\n if (classify == null) {\n fail(\n \"unsupported\",\n `${subject} outside ASCII needs Unicode identifier data ` +\n \"that is not linked.\",\n location,\n );\n }\n return classify(codePoint);\n}\n\nfunction readHexValue(state: ParseState, digits: number): number {\n const start = state.index;\n for (let offset = 0; offset < digits; offset += 1) {\n if (!isHexDigit(at(state, offset))) return -1;\n }\n state.index += digits;\n return Number.parseInt(state.source.slice(start, state.index), 16);\n}\n\n/**\n * Read one `\\u` escape after its `u`.\n *\n * `unicodeSyntax` selects the RegExpUnicodeEscapeSequence grammar\n * parameter. Only the unicode form admits a braced code point and joins a\n * lead surrogate escape to a following trail surrogate escape, which is\n * what makes an escaped supplementary code point equal to a written one.\n * Without it the same text is two independent code units. A group name\n * always uses the unicode form, whatever the flag set says.\n */\nfunction readUnicodeEscape(\n state: ParseState,\n unicodeSyntax: boolean,\n start: number,\n): number {\n if (unicodeSyntax && at(state, 0) === \"{\") {\n state.index += 1;\n const digitStart = state.index;\n while (isHexDigit(at(state, 0))) state.index += 1;\n if (state.index === digitStart || at(state, 0) !== \"}\") {\n fail(\"invalid\", \"A braced Unicode escape is incomplete.\", {\n end: state.index,\n start,\n });\n }\n const value = Number.parseInt(\n state.source.slice(digitStart, state.index),\n 16,\n );\n state.index += 1;\n if (value > 0x10_ffff) {\n fail(\"invalid\", \"A Unicode escape is above the code point range.\", {\n end: state.index,\n start,\n });\n }\n return value;\n }\n const value = readHexValue(state, 4);\n if (value < 0) {\n // A group name always uses the unicode form, so only a character\n // escape in a pattern without `u` or `v` reaches Annex B's identity\n // escape here. It names the `u` alone and leaves what follows to the\n // next term, which is how `\\u{2}` repeats a `u` without the flag.\n const location = { end: state.index, start };\n const message = \"A Unicode escape needs four hexadecimal digits.\";\n if (unicodeSyntax) fail(\"invalid\", message, location);\n if (state.annexB) return 0x75;\n refuseAnnexB(state, message, \"An incomplete Unicode escape\", location);\n }\n if (\n unicodeSyntax &&\n value >= 0xd800 &&\n value <= 0xdbff &&\n state.source.startsWith(\"\\\\u\", state.index)\n ) {\n const resume = state.index;\n state.index += 2;\n const trail = readHexValue(state, 4);\n if (trail >= 0xdc00 && trail <= 0xdfff) {\n return (value - 0xd800) * 0x400 + (trail - 0xdc00) + 0x1_0000;\n }\n state.index = resume;\n }\n return value;\n}\n\n/** Whether one character is an OctalDigit. */\nfunction isOctalDigit(character: string | undefined): boolean {\n return character != null && character >= \"0\" && character <= \"7\";\n}\n\n/**\n * Read one LegacyOctalEscapeSequence at its first digit.\n *\n * The grammar takes three digits only when the first is at most 3, so the\n * value never exceeds 0o377, and it takes the longest sequence its\n * lookahead restrictions allow: `\\47` is one escape and `\\477` is that\n * escape followed by a `7`.\n */\nfunction readLegacyOctalEscape(state: ParseState): number {\n const first = at(state, 0) ?? \"0\";\n let value = Number(first);\n state.index += 1;\n if (!isOctalDigit(at(state, 0))) return value;\n value = value * 8 + Number(at(state, 0));\n state.index += 1;\n if (first > \"3\" || !isOctalDigit(at(state, 0))) return value;\n value = value * 8 + Number(at(state, 0));\n state.index += 1;\n return value;\n}\n\n/**\n * Read one character escape after its backslash and return a code point.\n *\n * Without Annex B's grammar, a legacy octal escape and an identity escape\n * over an identifier character are rejected rather than accepted for a\n * pattern without `u` or `v`. With it, `inClass` decides how `\\c` without\n * an ASCII letter reads: a class admits a decimal digit or `_` as its\n * control letter, and otherwise the backslash is a character of its own\n * and the `c` stays for the next atom.\n */\nfunction readCharacterEscape(\n state: ParseState,\n start: number,\n inClass: boolean,\n): number {\n const character = at(state, 0);\n if (character == null) {\n fail(\"invalid\", \"A pattern cannot end with a backslash.\", {\n end: state.index,\n start,\n });\n }\n const control = controlEscapes.get(character);\n if (control != null) {\n state.index += 1;\n return control;\n }\n if (character === \"c\") {\n const letter = at(state, 1);\n if (\n letter == null ||\n !((letter >= \"a\" && letter <= \"z\") || (letter >= \"A\" && letter <= \"Z\"))\n ) {\n if (state.annexB) {\n if (inClass && (isDecimalDigit(letter) || letter === \"_\")) {\n state.index += 2;\n return (letter?.charCodeAt(0) ?? 0) % 32;\n }\n return 0x5c;\n }\n refuseAnnexB(\n state,\n \"A control escape needs an ASCII letter.\",\n \"A control escape without an ASCII letter\",\n { end: state.index + 1, start },\n );\n }\n state.index += 2;\n return letter.charCodeAt(0) % 32;\n }\n if (state.annexB && isOctalDigit(character)) {\n return readLegacyOctalEscape(state);\n }\n if (character === \"0\") {\n if (isDecimalDigit(at(state, 1))) {\n refuseAnnexB(\n state,\n \"A legacy octal escape is outside the candidate edition.\",\n \"A legacy octal escape\",\n { end: state.index + 2, start },\n );\n }\n state.index += 1;\n return 0;\n }\n if (character === \"x\") {\n state.index += 1;\n const value = readHexValue(state, 2);\n if (value < 0) {\n if (state.annexB) return 0x78;\n refuseAnnexB(\n state,\n \"A hexadecimal escape needs two hexadecimal digits.\",\n \"An incomplete hexadecimal escape\",\n { end: state.index, start },\n );\n }\n return value;\n }\n if (character === \"u\") {\n state.index += 1;\n return readUnicodeEscape(state, state.unicodeMode, start);\n }\n const escaped = readCharacter(state);\n if (state.unicodeMode) {\n const text = String.fromCodePoint(escaped.value);\n if (!syntaxCharacters.has(text) && text !== \"/\") {\n fail(\"invalid\", \"This identity escape is not allowed.\", {\n end: state.index,\n start,\n });\n }\n return escaped.value;\n }\n const location = { end: state.index, start };\n if (escaped.value === 0x6b && state.groupNameDeclared) {\n fail(\"invalid\", \"This identity escape is not allowed.\", location);\n }\n // Annex B's identity escape admits every source character but `c`, and\n // `k` once the pattern declares a group name, both decided above.\n if (state.annexB) return escaped.value;\n if (\n identifierProperty(\n state,\n escaped.value,\n \"continue\",\n \"An identity escape\",\n location,\n )\n ) {\n refuseAnnexB(\n state,\n \"This identity escape is not allowed.\",\n \"This identity escape\",\n location,\n );\n }\n return escaped.value;\n}\n\n/**\n * The six CharacterClassEscape spellings, keyed by exact letter.\n *\n * The uppercase spelling of each is its complement, and no other letter\n * names a class escape, so the table is matched literally rather than\n * through a case conversion that another letter could reach.\n */\nconst classEscapeSets = new Map<\n string,\n { readonly negated: boolean; readonly set: RegExpClassEscapeSet }\n>([\n [\"D\", { negated: true, set: \"digit\" }],\n [\"S\", { negated: true, set: \"space\" }],\n [\"W\", { negated: true, set: \"word\" }],\n [\"d\", { negated: false, set: \"digit\" }],\n [\"s\", { negated: false, set: \"space\" }],\n [\"w\", { negated: false, set: \"word\" }],\n]);\n\nfunction readClassEscape(\n state: ParseState,\n start: number,\n): RegExpClassEscape | undefined {\n const character = at(state, 0);\n const selected =\n character == null ? undefined : classEscapeSets.get(character);\n if (selected == null) return undefined;\n state.index += 1;\n return {\n kind: \"class-escape\",\n negated: selected.negated,\n set: selected.set,\n span: span(start, state.index),\n };\n}\n\n/**\n * Whether one text is a UnicodePropertyName.\n *\n * The grammar spells a name with ASCII letters and low lines and a value\n * with those and decimal digits, so a name is checked here rather than\n * left to whichever unit resolves it against Unicode data.\n */\nfunction propertyNameCharacters(text: string): boolean {\n return text.length > 0 && /^[A-Za-z_]+$/u.test(text);\n}\n\n/** Whether one text is a UnicodePropertyValue or a lone name or value. */\nfunction propertyValueCharacters(text: string): boolean {\n return text.length > 0 && /^[A-Za-z_0-9]+$/u.test(text);\n}\n\n/**\n * Read one `\\p` or `\\P` escape after its backslash.\n *\n * The escape only exists under `u` and `v`; elsewhere `p` is an\n * identifier character, so the backslash form is an invalid identity\n * escape rather than a property reference. A property name is an early\n * error unless a caller both admits the point and resolves the name, so\n * an unresolvable name is never accepted for lack of a resolver.\n */\nfunction readUnicodePropertyEscape(\n state: ParseState,\n start: number,\n): RegExpUnicodePropertyEscape | undefined {\n const character = at(state, 0);\n if (!state.unicodeMode || (character !== \"p\" && character !== \"P\")) {\n return undefined;\n }\n state.index += 1;\n if (!eat(state, \"{\")) {\n fail(\"invalid\", \"A Unicode property escape needs a braced name.\", {\n end: state.index,\n start,\n });\n }\n const nameStart = state.index;\n while (!done(state) && at(state, 0) !== \"}\" && at(state, 0) !== \"=\") {\n state.index += 1;\n }\n const first = state.source.slice(nameStart, state.index);\n let second: string | undefined;\n if (at(state, 0) === \"=\") {\n state.index += 1;\n const valueStart = state.index;\n while (!done(state) && at(state, 0) !== \"}\") state.index += 1;\n second = state.source.slice(valueStart, state.index);\n }\n if (!eat(state, \"}\")) {\n fail(\"invalid\", \"A Unicode property escape is unterminated.\", {\n end: state.index,\n start,\n });\n }\n const location = span(start, state.index);\n const named =\n second == null\n ? propertyValueCharacters(first)\n : propertyNameCharacters(first) && propertyValueCharacters(second);\n if (!named) {\n fail(\"invalid\", \"A Unicode property escape names nothing valid.\", location);\n }\n if (!admits(state, \"unicode-property-escapes\")) {\n fail(\n \"unsupported\",\n \"A Unicode property escape is not admitted yet.\",\n location,\n );\n }\n const resolve = state.extensions.unicodeProperty;\n if (resolve == null) {\n fail(\n \"unsupported\",\n \"A Unicode property escape needs property data that is not linked.\",\n location,\n );\n }\n const escape: RegExpUnicodePropertyEscape = {\n kind: \"unicode-property\",\n negated: character === \"P\",\n property: first,\n span: location,\n ...includePropertiesWhen(() => {\n if (second == null) return undefined;\n return { value: second };\n }),\n };\n if (\n !state.flags.unicodeSets &&\n escape.value == null &&\n unicodeStringProperties.has(escape.property)\n ) {\n fail(\n \"invalid\",\n \"A Unicode property of strings requires the v flag.\",\n location,\n );\n }\n if (!resolve(escape)) {\n if (\n state.flags.unicodeSets &&\n !escape.negated &&\n escape.value == null &&\n unicodeStringProperties.has(escape.property)\n ) {\n fail(\n \"unsupported\",\n \"A Unicode property of strings is not admitted yet.\",\n location,\n );\n }\n fail(\"invalid\", \"This Unicode property is not defined.\", location);\n }\n return escape;\n}\n\n/**\n * Count the left-capturing parentheses in a pattern text.\n *\n * This is CountLeftCapturingParensWithin over the whole pattern, which\n * Annex B needs before the parse reaches the groups. The scan skips an\n * escape and the inside of a character class, and it counts `(?<` only\n * when a group name rather than a lookbehind introducer follows. A text\n * the parse later rejects may count differently, but then no reading of\n * its escapes is ever returned.\n */\nfunction countCapturingGroups(source: string): number {\n let count = 0;\n let insideClass = false;\n for (let index = 0; index < source.length; index += 1) {\n const character = source[index];\n if (character === \"\\\\\") {\n index += 1;\n continue;\n }\n if (insideClass) {\n if (character === \"]\") insideClass = false;\n continue;\n }\n if (character === \"[\") {\n insideClass = true;\n continue;\n }\n if (character !== \"(\") continue;\n if (source[index + 1] !== \"?\") {\n count += 1;\n continue;\n }\n if (source[index + 2] !== \"<\") continue;\n const next = source[index + 3];\n if (next !== \"=\" && next !== \"!\") count += 1;\n }\n return count;\n}\n\n/**\n * Whether the pattern text holds a GroupSpecifier.\n *\n * The scan skips an escape and the inside of a character class, where\n * `(?<` is ordinary text rather than an introducer, and it excludes the\n * two lookbehind introducers that share the first three characters.\n */\nfunction scanForGroupName(source: string): boolean {\n let insideClass = false;\n for (let index = 0; index < source.length; index += 1) {\n const character = source[index];\n if (character === \"\\\\\") {\n index += 1;\n continue;\n }\n if (insideClass) {\n if (character === \"]\") insideClass = false;\n continue;\n }\n if (character === \"[\") {\n insideClass = true;\n continue;\n }\n if (character !== \"(\") continue;\n if (source[index + 1] !== \"?\" || source[index + 2] !== \"<\") continue;\n const next = source[index + 3];\n if (next !== \"=\" && next !== \"!\") return true;\n }\n return false;\n}\n\n/**\n * Read one `<name>` group specifier after its introducer.\n *\n * Both spellings that reach this reader parse with the grammar's\n * named-reference production active: a declaration is a group specifier\n * by construction, and a `\\k` reference reaches it only where the pattern\n * declares a group name or carries `u` or `v`. A malformed name is\n * therefore the edition's own early error rather than an Annex B\n * boundary.\n */\nfunction readGroupName(state: ParseState, start: number): string {\n if (!eat(state, \"<\")) {\n fail(\"invalid\", \"A group name must be enclosed in angle brackets.\", {\n end: state.index,\n start,\n });\n }\n let name = \"\";\n while (!done(state) && at(state, 0) !== \">\") {\n const characterStart = state.index;\n let codePoint: number;\n if (eat(state, \"\\\\\")) {\n if (!eat(state, \"u\")) {\n fail(\"invalid\", \"A group name escape must be a Unicode escape.\", {\n end: state.index,\n start: characterStart,\n });\n }\n codePoint = readUnicodeEscape(state, true, characterStart);\n } else {\n const start2 = state.index;\n codePoint = state.source.codePointAt(start2) ?? 0;\n state.index += codePoint > 0xffff ? 2 : 1;\n }\n const location = span(characterStart, state.index);\n const dollarOrLow = codePoint === 0x24 || codePoint === 0x5f;\n const admitted =\n name.length === 0\n ? dollarOrLow ||\n identifierProperty(\n state,\n codePoint,\n \"start\",\n \"A group name\",\n location,\n )\n : dollarOrLow ||\n codePoint === 0x200c ||\n codePoint === 0x200d ||\n identifierProperty(\n state,\n codePoint,\n \"continue\",\n \"A group name\",\n location,\n );\n if (!admitted) {\n fail(\n \"invalid\",\n \"This character is not allowed in a group name.\",\n location,\n );\n }\n name += String.fromCodePoint(codePoint);\n }\n if (name.length === 0 || !eat(state, \">\")) {\n fail(\"invalid\", \"A group name is incomplete.\", {\n end: state.index,\n start,\n });\n }\n return name;\n}\n\nfunction readModifierFlags(\n state: ParseState,\n start: number,\n): RegExpModifierFlag[] {\n const selected: RegExpModifierFlag[] = [];\n while (!done(state)) {\n const character = at(state, 0);\n if (character == null || !modifierFlags.has(character)) break;\n // SAFETY: Membership in modifierFlags establishes the modifier domain.\n if (selected.includes(character as RegExpModifierFlag)) {\n fail(\"invalid\", \"A modifier group repeats a flag.\", {\n end: state.index + 1,\n start,\n });\n }\n // SAFETY: Membership in modifierFlags establishes the modifier domain.\n selected.push(character as RegExpModifierFlag);\n state.index += 1;\n }\n return selected;\n}\n\nfunction classItemValue(item: RegExpClassItem): RegExpCharacter | undefined {\n return item.kind === \"character\" ? item : undefined;\n}\n\nfunction parseClassStringDisjunction(\n state: ParseState,\n): RegExpClassStringDisjunction {\n const start = state.index;\n state.index += 3;\n const strings: RegExpCharacter[][] = [];\n let characters: RegExpCharacter[] = [];\n for (;;) {\n if (done(state)) {\n fail(\"invalid\", \"A class string disjunction is unterminated.\", {\n end: state.index,\n start,\n });\n }\n if (eat(state, \"|\")) {\n strings.push(characters);\n characters = [];\n continue;\n }\n if (eat(state, \"}\")) {\n strings.push(characters);\n break;\n }\n const characterStart = state.index;\n let value: number;\n if (eat(state, \"\\\\\")) {\n if (eat(state, \"b\")) {\n value = 0x08;\n } else {\n value = readClassSetCharacterEscape(state, characterStart);\n }\n } else {\n validateClassSetCharacter(state);\n value = readCharacter(state).value;\n }\n characters.push({\n kind: \"character\",\n span: span(characterStart, state.index),\n value,\n });\n }\n return {\n kind: \"class-strings\",\n span: span(start, state.index),\n strings,\n };\n}\n\nfunction validateClassSetCharacter(state: ParseState): void {\n const firstCharacter = at(state, 0);\n if (\n firstCharacter == null ||\n firstCharacter === \"]\" ||\n state.source.startsWith(\"&&\", state.index) ||\n state.source.startsWith(\"--\", state.index)\n ) {\n fail(\n \"invalid\",\n \"A class set operator needs an operand.\",\n span(state.index, Math.min(state.index + 2, state.source.length)),\n );\n }\n if (classSetSyntaxCharacters.has(firstCharacter)) {\n fail(\n \"invalid\",\n \"A class set syntax character must be escaped.\",\n span(state.index, state.index + 1),\n );\n }\n if (\n firstCharacter === at(state, 1) &&\n classSetReservedDoublePunctuators.has(firstCharacter)\n ) {\n fail(\n \"invalid\",\n \"A doubled class set punctuator must be escaped.\",\n span(state.index, state.index + 2),\n );\n }\n}\n\nfunction parseClassSetOperand(state: ParseState): RegExpClassSetOperand {\n if (at(state, 0) === \"[\") return parseUnicodeClassSet(state);\n if (state.source.startsWith(\"\\\\q{\", state.index)) {\n return parseClassStringDisjunction(state);\n }\n validateClassSetCharacter(state);\n const first = parseClassAtom(state);\n if (\n first.kind === \"character\" &&\n at(state, 0) === \"-\" &&\n at(state, 1) !== \"-\" &&\n at(state, 1) !== \"]\" &&\n at(state, 1) != null\n ) {\n state.index += 1;\n if (at(state, 0) === \"[\") {\n fail(\n \"invalid\",\n \"A nested class set cannot be a range bound.\",\n span(first.span.start, state.index + 1),\n );\n }\n validateClassSetCharacter(state);\n const second = parseClassAtom(state);\n if (second.kind !== \"character\" || first.value > second.value) {\n fail(\"invalid\", \"A character class range is invalid.\", {\n end: state.index,\n start: first.span.start,\n });\n }\n return {\n end: second,\n kind: \"range\",\n span: span(first.span.start, state.index),\n start: first,\n };\n }\n return first;\n}\n\nfunction classSetOperandMayContainStrings(\n operand: RegExpClassSetOperand,\n): boolean {\n if (operand.kind === \"class-strings\") {\n return operand.strings.some((characters) => characters.length !== 1);\n }\n if (operand.kind === \"unicode-property\") {\n return (\n !operand.negated &&\n operand.value == null &&\n unicodeStringProperties.has(operand.property)\n );\n }\n if (operand.kind !== \"class-set\") return false;\n if (operand.operation === \"union\") {\n return operand.operands.some(classSetOperandMayContainStrings);\n }\n if (operand.operation === \"intersection\") {\n return (\n operand.operands.length > 0 &&\n operand.operands.every(classSetOperandMayContainStrings)\n );\n }\n const first = operand.operands[0];\n return first != null && classSetOperandMayContainStrings(first);\n}\n\n/**\n * Parse one `v`-mode class set, charging the reviewed nesting budget.\n *\n * A nested class is an operand of its enclosing class, so this production\n * recurses through `parseClassSetOperand` exactly as a group recurses\n * through `parseDisjunction`. It shares the one `nestingDepth` budget so a\n * pattern that nests either way, or both at once, reports the owned located\n * `limit` error rather than exhausting the host stack.\n */\nfunction parseUnicodeClassSet(state: ParseState): RegExpUnicodeClassSet {\n const start = state.index;\n state.depth += 1;\n if (state.depth > state.limits.nestingDepth) {\n fail(\"limit\", \"A pattern nests above the reviewed depth limit.\", {\n end: state.index,\n start,\n });\n }\n state.index += 1;\n const negated = eat(state, \"^\");\n const operands: RegExpClassSetOperand[] = [];\n if (at(state, 0) !== \"]\") operands.push(parseClassSetOperand(state));\n let operation: RegExpUnicodeClassSet[\"operation\"] = \"union\";\n if (state.source.startsWith(\"&&\", state.index)) {\n operation = \"intersection\";\n } else if (state.source.startsWith(\"--\", state.index)) {\n operation = \"subtraction\";\n }\n if (operation !== \"union\" && operands[0]?.kind === \"range\") {\n fail(\n \"invalid\",\n \"A class set range cannot be an intersection or subtraction operand.\",\n operands[0].span,\n );\n }\n while (!done(state) && at(state, 0) !== \"]\") {\n if (operation === \"intersection\") {\n if (!state.source.startsWith(\"&&\", state.index)) {\n fail(\"invalid\", \"A class set mixes its operators.\", {\n end: state.index + 1,\n start: state.index,\n });\n }\n state.index += 2;\n if (at(state, 0) === \"&\") {\n fail(\n \"invalid\",\n \"A class set operator needs an operand.\",\n span(state.index - 2, state.index + 1),\n );\n }\n } else if (operation === \"subtraction\") {\n if (!state.source.startsWith(\"--\", state.index)) {\n fail(\"invalid\", \"A class set mixes its operators.\", {\n end: state.index + 1,\n start: state.index,\n });\n }\n state.index += 2;\n }\n const operand = parseClassSetOperand(state);\n if (operation !== \"union\" && operand.kind === \"range\") {\n fail(\n \"invalid\",\n \"A class set range cannot be an intersection or subtraction \" +\n \"operand.\",\n operand.span,\n );\n }\n operands.push(operand);\n }\n if (!eat(state, \"]\")) {\n fail(\"invalid\", \"A character class is unterminated.\", {\n end: state.index,\n start,\n });\n }\n const classSet: RegExpUnicodeClassSet = {\n kind: \"class-set\",\n negated,\n operands,\n operation,\n span: span(start, state.index),\n };\n if (negated && classSetOperandMayContainStrings(classSet)) {\n fail(\n \"invalid\",\n \"A negated character class may contain strings.\",\n classSet.span,\n );\n }\n state.depth -= 1;\n return classSet;\n}\n\nfunction parseCharacterClass(\n state: ParseState,\n): RegExpCharacterClass | RegExpUnicodeClassSet {\n const start = state.index;\n if (state.flags.unicodeSets) {\n if (!admits(state, \"class-set-notation\")) {\n fail(\n \"unsupported\",\n \"Class set notation is not admitted yet.\",\n span(start, start + 1),\n );\n }\n return parseUnicodeClassSet(state);\n }\n state.index += 1;\n const negated = eat(state, \"^\");\n const items: RegExpClassItem[] = [];\n for (;;) {\n if (done(state)) {\n fail(\"invalid\", \"A character class is unterminated.\", {\n end: state.index,\n start,\n });\n }\n if (eat(state, \"]\")) break;\n const first = parseClassAtom(state);\n if (at(state, 0) === \"-\" && at(state, 1) !== \"]\" && at(state, 1) != null) {\n const dash = state.index;\n state.index += 1;\n const second = parseClassAtom(state);\n const low = classItemValue(first);\n const high = classItemValue(second);\n if ((low == null || high == null) && state.annexB) {\n // Annex B's CharacterRangeOrUnion: a class escape at either end\n // makes the three atoms a union that includes the dash itself.\n items.push(\n first,\n { kind: \"character\", span: span(dash, dash + 1), value: 0x2d },\n second,\n );\n continue;\n }\n if (low == null || high == null) {\n refuseAnnexB(\n state,\n \"A character class range bound cannot be a class escape.\",\n \"A class escape as a character class range bound\",\n { end: state.index, start: first.span.start },\n );\n }\n if (low.value > high.value) {\n fail(\"invalid\", \"A character class range is out of order.\", {\n end: state.index,\n start: first.span.start,\n });\n }\n items.push({\n end: high,\n kind: \"range\",\n span: span(first.span.start, state.index),\n start: low,\n });\n continue;\n }\n items.push(first);\n }\n return {\n items,\n kind: \"character-class\",\n negated,\n span: span(start, state.index),\n };\n}\n\nfunction parseClassAtom(state: ParseState): RegExpClassItem {\n const start = state.index;\n if (!eat(state, \"\\\\\")) return readCharacter(state);\n if (at(state, 0) === \"b\") {\n state.index += 1;\n return { kind: \"character\", span: span(start, state.index), value: 8 };\n }\n const classEscape = readClassEscape(state, start);\n if (classEscape != null) return classEscape;\n const property = readUnicodePropertyEscape(state, start);\n if (property != null) return property;\n return {\n kind: \"character\",\n span: span(start, state.index),\n value: readClassSetCharacterEscape(state, start),\n };\n}\n\nfunction parseAtomEscape(state: ParseState, start: number): RegExpAtom {\n const character = at(state, 0);\n if (character != null && character >= \"1\" && character <= \"9\") {\n const digitStart = state.index;\n const digits = readDecimalDigits(state);\n const location = span(start, state.index);\n if (state.annexB && Number(digits) > state.captureCount) {\n /*\n * Annex B admits a DecimalEscape only up to the pattern's capture\n * count. Past it the same text is a legacy octal escape, or an\n * identity escape when it starts with 8 or 9, and the digits that\n * escape does not take are pattern characters.\n */\n state.index = digitStart;\n if (character >= \"8\") {\n state.index += 1;\n return {\n kind: \"character\",\n span: span(start, state.index),\n value: character.charCodeAt(0),\n };\n }\n const value = readLegacyOctalEscape(state);\n return { kind: \"character\", span: span(start, state.index), value };\n }\n /*\n * A pattern cannot declare more groups than its own text is long, so\n * an index too large to represent exactly still names no group. The\n * approximate value is only ever compared against the capture count,\n * and validation reports the ordinary early error for it.\n */\n const index = Number(digits);\n state.backreferences.push({ index, span: location });\n return { index, kind: \"backreference\", span: location };\n }\n if (character === \"k\") {\n state.index += 1;\n /*\n * Without a group specifier and without `u` or `v` the grammar never\n * enters its named-reference production, so Annex B reads the escape\n * as an identity escape whatever follows it. Reading a group name\n * here instead would report the shape of text the grammar never\n * looked at.\n */\n if (!state.unicodeMode && !state.groupNameDeclared) {\n if (state.annexB) {\n return {\n kind: \"character\",\n span: span(start, state.index),\n value: 0x6b,\n };\n }\n fail(\n \"unsupported\",\n annexBMessage(\n \"A named backreference in a pattern that declares no group name\",\n ),\n span(start, state.index),\n );\n }\n const name = readGroupName(state, start);\n const location = span(start, state.index);\n state.namedReferences.push({ name, span: location });\n const indices = state.namedReferenceIndices.get(name) ?? [];\n state.namedReferenceIndices.set(name, indices);\n return { indices, kind: \"named-backreference\", name, span: location };\n }\n const classEscape = readClassEscape(state, start);\n if (classEscape != null) return classEscape;\n const property = readUnicodePropertyEscape(state, start);\n if (property != null) return property;\n return {\n kind: \"character\",\n span: span(start, state.index),\n value: readCharacterEscape(state, start, false),\n };\n}\n\nfunction parseGroup(state: ParseState): RegExpAtom {\n const start = state.index;\n state.index += 1;\n if (eat(state, \"?\")) {\n if (eat(state, \":\")) {\n const body = parseDisjunction(state);\n expectGroupEnd(state, start);\n return { body, kind: \"group\", span: span(start, state.index) };\n }\n if (at(state, 0) === \"<\") {\n const name = readGroupName(state, start);\n const capture = declareCapture(state, start, name);\n const body = parseDisjunction(state);\n expectGroupEnd(state, start);\n return {\n body,\n index: capture,\n kind: \"capturing-group\",\n name,\n span: span(start, state.index),\n };\n }\n const enabled = readModifierFlags(state, start);\n const disabled = eat(state, \"-\") ? readModifierFlags(state, start) : [];\n if (!eat(state, \":\")) {\n fail(\"invalid\", \"This group prefix is not a valid group.\", {\n end: state.index + 1,\n start,\n });\n }\n if (enabled.length === 0 && disabled.length === 0) {\n fail(\"invalid\", \"A modifier group names no flag.\", {\n end: state.index,\n start,\n });\n }\n if (enabled.some((flag) => disabled.includes(flag))) {\n fail(\"invalid\", \"A modifier group both adds and removes a flag.\", {\n end: state.index,\n start,\n });\n }\n if (!admits(state, \"modifiers\")) {\n fail(\"unsupported\", \"An inline modifier group is not admitted yet.\", {\n end: state.index,\n start,\n });\n }\n const body = parseDisjunction(state);\n expectGroupEnd(state, start);\n return {\n body,\n disabled,\n enabled,\n kind: \"modifier-group\",\n span: span(start, state.index),\n };\n }\n const capture = declareCapture(state, start);\n const body = parseDisjunction(state);\n expectGroupEnd(state, start);\n return {\n body,\n index: capture,\n kind: \"capturing-group\",\n span: span(start, state.index),\n };\n}\n\nfunction declareCapture(\n state: ParseState,\n start: number,\n name?: string,\n): number {\n if (state.captures.length >= state.limits.capturingGroups) {\n fail(\"limit\", \"A pattern declares too many capturing groups.\", {\n end: state.index,\n start,\n });\n }\n const index = state.captures.length + 1;\n const location = span(start, state.index);\n state.captures.push({\n index,\n span: location,\n ...includePropertiesWhen(() => {\n if (name == null) return undefined;\n return { name };\n }),\n });\n if (name != null) {\n state.namedGroups.push({\n name,\n path: [...state.path],\n span: location,\n });\n }\n return index;\n}\n\nfunction expectGroupEnd(state: ParseState, start: number): void {\n if (!eat(state, \")\")) {\n fail(\"invalid\", \"A group is unterminated.\", { end: state.index, start });\n }\n}\n\nfunction parseAtom(state: ParseState): RegExpAtom {\n const start = state.index;\n const character = at(state, 0);\n if (character === \".\") {\n state.index += 1;\n return { kind: \"dot\", span: span(start, state.index) };\n }\n if (character === \"(\") return parseGroup(state);\n if (character === \"[\") return parseCharacterClass(state);\n if (character === \"\\\\\") {\n state.index += 1;\n return parseAtomEscape(state, start);\n }\n if (character === \"*\" || character === \"+\" || character === \"?\") {\n fail(\"invalid\", \"A quantifier has no atom to repeat.\", {\n end: start + 1,\n start,\n });\n }\n if (character === \"{\") {\n if (bracedQuantifierFollows(state)) {\n fail(\"invalid\", \"A quantifier has no atom to repeat.\", {\n end: start + 1,\n start,\n });\n }\n if (state.annexB) return readCharacter(state);\n refuseAnnexB(\n state,\n \"An unescaped brace is not a pattern character.\",\n \"An unescaped brace\",\n { end: start + 1, start },\n );\n }\n if ((character === \"]\" || character === \"}\") && !state.annexB) {\n refuseAnnexB(\n state,\n \"This character must be escaped.\",\n \"This unescaped character\",\n { end: start + 1, start },\n );\n }\n return readCharacter(state);\n}\n\n/**\n * The bounds one braced quantifier spells, before validation.\n *\n * The digits are retained because two bounds can round to one double\n * while their written values differ, and the edition compares the exact\n * mathematical values.\n */\ninterface QuantifierBounds {\n readonly maximum: number;\n readonly maximumDigits?: string;\n readonly minimum: number;\n readonly minimumDigits: string;\n}\n\n/** Compare two decimal digit strings by exact mathematical value. */\nfunction compareDecimalDigits(first: string, second: string): number {\n const left = first.replace(/^0+(?=\\d)/u, \"\");\n const right = second.replace(/^0+(?=\\d)/u, \"\");\n if (left.length !== right.length) return left.length - right.length;\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\n/**\n * Read a braced quantifier body after its `{`, or return undefined when\n * the text is not one. Annex B is outside the claim, so a `{` that starts\n * no quantifier is an error at the caller rather than a literal brace.\n *\n * Recognition is separate from validation: a quantifier that no atom\n * precedes is an error whatever its bounds say, so the bound order and\n * the reviewed bound limit are checked only where a quantifier is\n * grammatically admitted.\n */\nfunction readBracedQuantifier(state: ParseState): QuantifierBounds | undefined {\n const minimumDigits = readDecimalDigits(state);\n if (minimumDigits.length === 0) return undefined;\n const minimum = Number(minimumDigits);\n let maximum = minimum;\n let maximumDigits: string | undefined = minimumDigits;\n if (eat(state, \",\")) {\n const written = readDecimalDigits(state);\n maximumDigits = written.length === 0 ? undefined : written;\n maximum =\n maximumDigits == null ? Number.POSITIVE_INFINITY : Number(written);\n }\n if (!eat(state, \"}\")) return undefined;\n return {\n maximum,\n ...includePropertiesWhen(() => {\n if (maximumDigits == null) return undefined;\n return {\n maximumDigits,\n };\n }),\n minimum,\n minimumDigits,\n };\n}\n\nfunction validateQuantifierBounds(\n state: ParseState,\n bounds: QuantifierBounds,\n start: number,\n): QuantifierBounds {\n const location = { end: state.index, start };\n /*\n * The early error comes first: a quantifier whose written lower bound\n * exceeds its written upper bound is invalid at every limit, and the\n * exact digits decide it because two bounds can share one double.\n */\n if (\n bounds.maximumDigits != null &&\n compareDecimalDigits(bounds.minimumDigits, bounds.maximumDigits) > 0\n ) {\n fail(\n \"invalid\",\n \"A quantifier's lower bound is above its upper bound.\",\n location,\n );\n }\n const limit = String(state.limits.quantifierBound);\n const above = (digits: string): boolean =>\n compareDecimalDigits(digits, limit) > 0;\n if (\n above(bounds.minimumDigits) ||\n (bounds.maximumDigits != null && above(bounds.maximumDigits))\n ) {\n fail(\"limit\", \"A quantifier bound is above the reviewed limit.\", location);\n }\n return bounds;\n}\n\nfunction parseQuantifier(state: ParseState): RegExpQuantifier | undefined {\n const start = state.index;\n const character = at(state, 0);\n let bounds:\n | { readonly maximum: number; readonly minimum: number }\n | undefined;\n if (character === \"*\") {\n state.index += 1;\n bounds = { maximum: Number.POSITIVE_INFINITY, minimum: 0 };\n } else if (character === \"+\") {\n state.index += 1;\n bounds = { maximum: Number.POSITIVE_INFINITY, minimum: 1 };\n } else if (character === \"?\") {\n state.index += 1;\n bounds = { maximum: 1, minimum: 0 };\n } else if (character === \"{\") {\n state.index += 1;\n const braced = readBracedQuantifier(state);\n if (braced == null) {\n state.index = start;\n // Annex B reads the brace as an ExtendedPatternCharacter that the\n // next term consumes, so the atom before it stays unquantified.\n if (state.annexB) return undefined;\n refuseAnnexB(\n state,\n \"An unescaped brace is not a pattern character.\",\n \"An unescaped brace\",\n { end: start + 1, start },\n );\n }\n bounds = validateQuantifierBounds(state, braced, start);\n }\n if (bounds == null) return undefined;\n const greedy = !eat(state, \"?\");\n return {\n greedy,\n maximum: bounds.maximum,\n minimum: bounds.minimum,\n span: span(start, state.index),\n };\n}\n\nfunction parseLookaround(state: ParseState): RegExpLookaround | undefined {\n const start = state.index;\n const behind = state.source.startsWith(\"(?<=\", start)\n ? false\n : state.source.startsWith(\"(?<!\", start)\n ? true\n : undefined;\n const ahead = state.source.startsWith(\"(?=\", start)\n ? false\n : state.source.startsWith(\"(?!\", start)\n ? true\n : undefined;\n if (behind == null && ahead == null) return undefined;\n const negated = behind ?? ahead ?? false;\n state.index += behind == null ? 3 : 4;\n const body = parseDisjunction(state);\n expectGroupEnd(state, start);\n return {\n body,\n direction: behind == null ? \"ahead\" : \"behind\",\n kind: \"lookaround\",\n negated,\n span: span(start, state.index),\n };\n}\n\nfunction parseTerm(state: ParseState): RegExpTerm {\n const start = state.index;\n const lookaround = parseLookaround(state);\n if (lookaround != null) {\n if (state.annexB && lookaround.direction === \"ahead\") {\n return quantifyLookahead(state, lookaround);\n }\n return rejectQuantifier(state, lookaround);\n }\n const character = at(state, 0);\n if (character === \"^\" || character === \"$\") {\n state.index += 1;\n return rejectQuantifier(state, {\n assertion: character === \"^\" ? \"start\" : \"end\",\n kind: \"assertion\",\n span: span(start, state.index),\n });\n }\n if (character === \"\\\\\" && (at(state, 1) === \"b\" || at(state, 1) === \"B\")) {\n const negated = at(state, 1) === \"B\";\n state.index += 2;\n return rejectQuantifier(state, {\n assertion: negated ? \"non-word-boundary\" : \"word-boundary\",\n kind: \"assertion\",\n span: span(start, state.index),\n });\n }\n const atom = parseAtom(state);\n const quantifier = parseQuantifier(state);\n if (quantifier == null) return atom;\n return {\n atom,\n kind: \"quantified\",\n quantifier,\n span: span(start, state.index),\n };\n}\n\n/**\n * Read Annex B's QuantifiableAssertion Quantifier.\n *\n * The edition gives a quantified lookahead the semantics of a quantified\n * atom whose matcher is the assertion, which is exactly a non-capturing\n * group around it. The group therefore stands in for the lookahead as the\n * repeated atom, with the lookahead's span, so the matcher and the C\n * backend need no separate repetition form.\n */\nfunction quantifyLookahead(\n state: ParseState,\n lookahead: RegExpLookaround,\n): RegExpTerm {\n const quantifier = parseQuantifier(state);\n if (quantifier == null) return lookahead;\n const location = lookahead.span;\n return {\n atom: {\n body: {\n alternatives: [\n { kind: \"alternative\", span: location, terms: [lookahead] },\n ],\n kind: \"disjunction\",\n span: location,\n },\n kind: \"group\",\n span: location,\n },\n kind: \"quantified\",\n quantifier,\n span: span(location.start, state.index),\n };\n}\n\n/**\n * Reject a quantifier applied to an assertion. The edition admits a\n * quantified assertion only through Annex B, and Annex B quantifies a\n * lookahead alone, which `quantifyLookahead` reads. An edge assertion, a\n * word boundary, and a lookbehind are unquantifiable in every mode, so\n * only a lookahead in a parse without Annex B's grammar reports the\n * `unsupported` kind.\n */\nfunction rejectQuantifier(state: ParseState, term: RegExpTerm): RegExpTerm {\n const character = at(state, 0);\n const quantified =\n character === \"*\" ||\n character === \"+\" ||\n character === \"?\" ||\n (character === \"{\" && bracedQuantifierFollows(state));\n if (quantified) {\n const location = { end: state.index + 1, start: state.index };\n const message = \"An assertion cannot be quantified.\";\n if (term.kind !== \"lookaround\" || term.direction !== \"ahead\") {\n fail(\"invalid\", message, location);\n }\n refuseAnnexB(state, message, \"A quantified lookahead\", location);\n }\n return term;\n}\n\n/**\n * Whether the `{` at the cursor starts a quantifier.\n *\n * A brace that starts no quantifier is its own early error, reported\n * where the next term reads it, so an assertion followed by one is not\n * described as a quantified assertion.\n */\nfunction bracedQuantifierFollows(state: ParseState): boolean {\n const resume = state.index;\n try {\n state.index += 1;\n return readBracedQuantifier(state) != null;\n } finally {\n state.index = resume;\n }\n}\n\nfunction parseAlternative(state: ParseState): RegExpAlternative {\n const start = state.index;\n const terms: RegExpTerm[] = [];\n while (!done(state) && at(state, 0) !== \"|\" && at(state, 0) !== \")\") {\n terms.push(parseTerm(state));\n }\n return { kind: \"alternative\", span: span(start, state.index), terms };\n}\n\nfunction parseDisjunction(state: ParseState): RegExpDisjunction {\n const start = state.index;\n state.depth += 1;\n if (state.depth > state.limits.nestingDepth) {\n fail(\"limit\", \"A pattern nests above the reviewed depth limit.\", {\n end: state.index,\n start,\n });\n }\n const disjunction = state.disjunctionCount;\n state.disjunctionCount += 1;\n const alternatives: RegExpAlternative[] = [];\n for (let index = 0; ; index += 1) {\n state.path.push({ alternative: index, disjunction });\n alternatives.push(parseAlternative(state));\n state.path.pop();\n if (!eat(state, \"|\")) break;\n }\n state.depth -= 1;\n return {\n alternatives,\n kind: \"disjunction\",\n span: span(start, state.index),\n };\n}\n\nfunction parseFlags(text: string): RegExpFlags {\n const seen = new Set<string>();\n const admitted = \"dgimsuvy\";\n for (let index = 0; index < text.length; index += 1) {\n const character = text[index] ?? \"\";\n if (!admitted.includes(character)) {\n fail(\n \"invalid\",\n \"This regular expression flag is not defined.\",\n span(index, index + 1),\n \"flags\",\n );\n }\n if (seen.has(character)) {\n fail(\n \"invalid\",\n \"This regular expression flag is repeated.\",\n span(index, index + 1),\n \"flags\",\n );\n }\n seen.add(character);\n }\n if (seen.has(\"u\") && seen.has(\"v\")) {\n fail(\n \"invalid\",\n \"The u and v flags cannot be combined.\",\n span(0, text.length),\n \"flags\",\n );\n }\n return {\n dotAll: seen.has(\"s\"),\n global: seen.has(\"g\"),\n hasIndices: seen.has(\"d\"),\n ignoreCase: seen.has(\"i\"),\n multiline: seen.has(\"m\"),\n sticky: seen.has(\"y\"),\n text,\n unicode: seen.has(\"u\"),\n unicodeSets: seen.has(\"v\"),\n };\n}\n\n/**\n * Whether two groups with one name can both participate in a match.\n *\n * They cannot when some enclosing disjunction holds them in different\n * alternatives, which is the condition the candidate edition uses to\n * admit a repeated group name.\n */\nfunction mightBothParticipate(\n first: readonly AlternativePath[],\n second: readonly AlternativePath[],\n): boolean {\n const shared = Math.min(first.length, second.length);\n for (let index = 0; index < shared; index += 1) {\n const left = first[index];\n const right = second[index];\n if (left == null || right == null) break;\n if (left.disjunction !== right.disjunction) break;\n if (left.alternative !== right.alternative) return false;\n }\n return true;\n}\n\n/**\n * Order two alternative paths so that adjacent pairs decide the whole\n * set.\n *\n * Exclusivity is transitive along this order: if a sorted neighbor pair\n * diverges at a disjunction, every wider pair diverges at one too, so a\n * sorted scan replaces a comparison of every pair with every other.\n */\nfunction comparePaths(\n first: readonly AlternativePath[],\n second: readonly AlternativePath[],\n): number {\n const shared = Math.min(first.length, second.length);\n for (let index = 0; index < shared; index += 1) {\n const left = first[index];\n const right = second[index];\n if (left == null || right == null) break;\n if (left.disjunction !== right.disjunction) {\n return left.disjunction - right.disjunction;\n }\n if (left.alternative !== right.alternative) {\n return left.alternative - right.alternative;\n }\n }\n return first.length - second.length;\n}\n\nfunction duplicateNameErrors(\n groups: readonly NamedGroupRecord[],\n): readonly RegExpPatternError[] {\n const errors: RegExpPatternError[] = [];\n const byName = new Map<string, NamedGroupRecord[]>();\n for (const group of groups) {\n const existing = byName.get(group.name) ?? [];\n existing.push(group);\n byName.set(group.name, existing);\n }\n for (const named of byName.values()) {\n if (named.length < 2) continue;\n const ordered = named.toSorted((first, second) =>\n comparePaths(first.path, second.path),\n );\n for (let index = 1; index < ordered.length; index += 1) {\n const earlier = ordered[index - 1];\n const later = ordered[index];\n if (earlier == null || later == null) continue;\n if (!mightBothParticipate(earlier.path, later.path)) continue;\n const reported = later.span.start >= earlier.span.start ? later : earlier;\n errors.push({\n kind: \"invalid\",\n message:\n \"This group name repeats one that can participate in the \" +\n \"same match.\",\n section: \"pattern\",\n span: reported.span,\n });\n }\n }\n return errors;\n}\n\nfunction validate(state: ParseState): readonly RegExpPatternError[] {\n const errors: RegExpPatternError[] = [];\n const total = state.captures.length;\n for (const reference of state.backreferences) {\n if (reference.index > total) {\n // Annex B reads a decimal escape past the capture count as a legacy\n // octal or identity escape rather than as a reference.\n errors.push(\n annexBError(\n state,\n \"This backreference names no capturing group.\",\n \"A backreference that names no capturing group\",\n reference.span,\n ),\n );\n }\n }\n errors.push(...duplicateNameErrors(state.namedGroups));\n const indexByName = new Map<string, number[]>();\n for (const capture of state.captures) {\n if (capture.name == null) continue;\n const indices = indexByName.get(capture.name) ?? [];\n indices.push(capture.index);\n indexByName.set(capture.name, indices);\n }\n /*\n * A reference reaches validation only where the grammar's\n * named-reference production was active, so a name it does not declare\n * is an early error a web browser reports too.\n */\n for (const reference of state.namedReferences) {\n if (indexByName.has(reference.name)) continue;\n errors.push({\n kind: \"invalid\",\n message: \"This named backreference names no capturing group.\",\n section: \"pattern\",\n span: reference.span,\n });\n }\n for (const [name, shared] of state.namedReferenceIndices) {\n shared.push(...(indexByName.get(name) ?? []));\n }\n errors.sort((first, second) => first.span.start - second.span.start);\n return errors;\n}\n\n/**\n * Keep one reported span inside the text it addresses.\n *\n * A production that reports the character it expected can name an offset\n * one past the end when the pattern stops early, so the reported span is\n * clamped once here rather than at every such production.\n */\nfunction clampError(\n error: RegExpPatternError,\n input: RegExpPatternInput,\n): RegExpPatternError {\n const length =\n error.section === \"flags\" ? input.flags.length : input.source.length;\n const start = Math.min(Math.max(error.span.start, 0), length);\n const end = Math.min(Math.max(error.span.end, start), length);\n if (start === error.span.start && end === error.span.end) return error;\n return { ...error, span: { end, start } };\n}\n\n/**\n * Parse and validate one pattern and flag text.\n *\n * The result is the owned representation of the pattern; no bootstrap\n * parser node reaches it, and no construct is admitted whose semantics\n * this unit cannot describe.\n */\nexport function parseRegExpPattern(\n input: RegExpPatternInput,\n): RegExpPatternResult {\n const limits = input.limits ?? defaultRegExpPatternLimits;\n try {\n if (input.source.length > limits.sourceLength) {\n fail(\"limit\", \"A pattern is longer than the reviewed limit.\", {\n end: input.source.length,\n start: 0,\n });\n }\n const flags = parseFlags(input.flags);\n const unicodeMode = regExpUnicodeMode(flags);\n const annexB = input.annexB !== false && !unicodeMode;\n const state: ParseState = {\n annexB,\n backreferences: [],\n captureCount: annexB ? countCapturingGroups(input.source) : 0,\n captures: [],\n depth: 0,\n disjunctionCount: 0,\n extensions: input.extensions ?? noExtensions,\n flags,\n groupNameDeclared: scanForGroupName(input.source),\n index: 0,\n limits,\n namedGroups: [],\n namedReferenceIndices: new Map(),\n namedReferences: [],\n path: [],\n source: input.source,\n unicodeMode,\n };\n const body = parseDisjunction(state);\n if (!done(state)) {\n fail(\"invalid\", \"This character must be escaped.\", {\n end: state.index + 1,\n start: state.index,\n });\n }\n const errors = validate(state).map((error) => clampError(error, input));\n if (errors.length > 0) return { errors, parsed: false };\n const groupNames = [\n ...new Set(\n state.captures.flatMap((capture) =>\n capture.name == null ? [] : [capture.name],\n ),\n ),\n ];\n const pattern: RegExpPattern = {\n body,\n captures: state.captures,\n flags,\n groupNames,\n kind: \"pattern\",\n source: input.source,\n };\n return { errors: [], parsed: true, pattern };\n } catch (error) {\n if (error instanceof PatternFailure) {\n return {\n errors: [clampError(error.error, input)],\n parsed: false,\n };\n }\n throw error;\n }\n}\n\n/**\n * Parse one regular expression literal recorded by a frontend.\n *\n * The literal already carries its own source location, so the returned\n * spans stay relative to the pattern and flag text and the frontend maps\n * them back into the source it owns.\n */\nexport function parseRegExpLiteral(\n literal: RegExpLiteralSyntax,\n options: RegExpPatternOptions = {},\n): RegExpPatternResult {\n return parseRegExpPattern({\n flags: literal.flags,\n source: literal.pattern,\n ...options,\n });\n}\n"],"mappings":";;;AAmCA,SAAS,sBACP,YACoD;CACpD,OAAO,WAAW,KAAK,CAAC;AAC1B;;AAGA,MAAM,mCAAmB,IAAI,IAAI,iBAAiB;;AAGlD,MAAM,iCAAiB,IAAI,IAAoB;CAC7C,CAAC,KAAK,EAAI;CACV,CAAC,KAAK,EAAI;CACV,CAAC,KAAK,EAAI;CACV,CAAC,KAAK,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MAAM,aAAa,CACjB,GAAG,IAAI,IACL,MAAM,SAAS,SAAS,YACtB,QAAQ,QAAQ,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,CAC3C,CACF,CACF;EASA,OAAO;GAAE,QAAQ,CAAC;GAAG,QAAQ;GAAM;IAPjC;IACA,UAAU,MAAM;IAChB;IACA;IACA,MAAM;IACN,QAAQ,MAAM;GAEyB;EAAE;CAC7C,SAAS,OAAO;EACd,IAAI,iBAAiB,gBACnB,OAAO;GACL,QAAQ,CAAC,WAAW,MAAM,OAAO,KAAK,CAAC;GACvC,QAAQ;EACV;EAEF,MAAM;CACR;AACF;;;;;;;;AASA,SAAgB,mBACd,SACA,UAAgC,CAAC,GACZ;CACrB,OAAO,mBAAmB;EACxB,OAAO,QAAQ;EACf,QAAQ,QAAQ;EAChB,GAAG;CACL,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"regexp-parse.js","names":[],"sources":["../src/regexp-parse.ts"],"sourcesContent":["/*\n * Oseo, an ahead-of-time compiler for JavaScript and TypeScript.\n * Copyright (C) 2026 Hong Minhee <https://hongminhee.org/>\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <https://www.gnu.org/licenses/>.\n */\n\nimport {\n defaultRegExpPatternLimits,\n regExpUnicodeMode,\n type RegExpAlternative,\n type RegExpAtom,\n type RegExpCapture,\n type RegExpCharacter,\n type RegExpCharacterClass,\n type RegExpClassSetOperand,\n type RegExpClassStringDisjunction,\n type RegExpClassEscape,\n type RegExpClassEscapeSet,\n type RegExpClassItem,\n type RegExpDisjunction,\n type RegExpErrorKind,\n type RegExpErrorSection,\n type RegExpExtensionPoint,\n type RegExpFlags,\n type RegExpLookaround,\n type RegExpModifierFlag,\n type RegExpPattern,\n type RegExpPatternError,\n type RegExpPatternExtensions,\n type RegExpPatternInput,\n type RegExpPatternLimits,\n type RegExpPatternOptions,\n type RegExpPatternResult,\n type RegExpQuantifier,\n type RegExpSpan,\n type RegExpTerm,\n type RegExpUnicodePropertyEscape,\n type RegExpUnicodeClassSet,\n} from \"./regexp.ts\";\nimport type { RegExpLiteralSyntax } from \"./syntax.ts\";\n\nfunction includePropertiesWhen<const Properties extends object>(\n properties: () => Properties | undefined,\n): Properties | { [Key in keyof Properties]?: never } {\n return properties() ?? {};\n}\n\n/** Characters the grammar reserves, which a pattern character excludes. */\nconst syntaxCharacters = new Set(\"^$\\\\.*+?()[]{}|\");\n\n/** The five ControlEscape spellings and the code points they name. */\nconst controlEscapes = new Map<string, number>([\n [\"f\", 0x0c],\n [\"n\", 0x0a],\n [\"r\", 0x0d],\n [\"t\", 0x09],\n [\"v\", 0x0b],\n]);\n\n/** Modifier flags one inline modifier group may enable or disable. */\nconst modifierFlags = new Set<string>([\"i\", \"m\", \"s\"]);\n\n/** Binary properties of strings admitted only by positive `v` escapes. */\nconst unicodeStringProperties = new Set<string>([\n \"Basic_Emoji\",\n \"Emoji_Keycap_Sequence\",\n \"RGI_Emoji\",\n \"RGI_Emoji_Flag_Sequence\",\n \"RGI_Emoji_Modifier_Sequence\",\n \"RGI_Emoji_Tag_Sequence\",\n \"RGI_Emoji_ZWJ_Sequence\",\n]);\n\n/** Characters that must be escaped inside a Unicode class set. */\nconst classSetSyntaxCharacters = new Set<string>(\"(){}[/-|\");\n\n/** Punctuators reserved when two equal copies occur in a class set. */\nconst classSetReservedDoublePunctuators = new Set<string>(\n \"!#$%&*+,.:;<=>?@^`~\",\n);\n\nfunction readClassSetCharacterEscape(state: ParseState, start: number): number {\n const character = at(state, 0);\n if (\n character != null &&\n ((state.unicodeMode && character === \"-\") ||\n (state.flags.unicodeSets &&\n classSetReservedDoublePunctuators.has(character)))\n ) {\n state.index += 1;\n return character.codePointAt(0) ?? 0;\n }\n return readCharacterEscape(state, start, true);\n}\n\nconst noExtensions: RegExpPatternExtensions = { admitted: [] };\n\n/**\n * One rejected construct, thrown so a deep production reports its own\n * location without every caller forwarding a failure value.\n */\nclass PatternFailure extends Error {\n readonly error: RegExpPatternError;\n\n constructor(error: RegExpPatternError) {\n super(error.message);\n this.error = error;\n }\n}\n\n/**\n * Where one alternative sits in the enclosing disjunctions.\n *\n * Two groups with one name are admitted only when some enclosing\n * disjunction places them in different alternatives, so each named group\n * retains the alternative it was parsed in.\n */\ninterface AlternativePath {\n readonly alternative: number;\n readonly disjunction: number;\n}\n\ninterface NamedGroupRecord {\n readonly name: string;\n readonly path: readonly AlternativePath[];\n readonly span: RegExpSpan;\n}\n\ninterface BackreferenceRecord {\n readonly index: number;\n readonly span: RegExpSpan;\n}\n\ninterface NamedReferenceRecord {\n readonly name: string;\n readonly span: RegExpSpan;\n}\n\ninterface ParseState {\n /**\n * Whether this parse follows Annex B's pattern grammar: the caller left\n * it on and the flag set has neither `u` nor `v`.\n */\n readonly annexB: boolean;\n readonly backreferences: BackreferenceRecord[];\n /**\n * The left-capturing parentheses in the whole pattern text, which\n * Annex B compares a decimal escape against before it has parsed the\n * groups the escape may name. Zero outside Annex B, where validation\n * decides every reference after the parse.\n */\n readonly captureCount: number;\n readonly captures: RegExpCapture[];\n readonly extensions: RegExpPatternExtensions;\n readonly flags: RegExpFlags;\n /**\n * Whether the pattern text declares a group name.\n *\n * The grammar sets its named-reference parameter exactly when the\n * pattern holds a GroupSpecifier, and Annex B reads `\\k` as an identity\n * escape only without one. A reference can precede the declaration that\n * decides this, so the whole text answers it once before parsing rather\n * than each reference rescanning what it cannot see yet.\n */\n readonly groupNameDeclared: boolean;\n readonly limits: RegExpPatternLimits;\n readonly namedGroups: NamedGroupRecord[];\n /**\n * One index list per referenced name, shared by every node that names\n * it. Validation resolves each list once, so a pattern with many\n * references to one name holds one list rather than a copy per node.\n */\n readonly namedReferenceIndices: Map<string, number[]>;\n readonly namedReferences: NamedReferenceRecord[];\n readonly path: AlternativePath[];\n readonly source: string;\n readonly unicodeMode: boolean;\n depth: number;\n disjunctionCount: number;\n index: number;\n}\n\nfunction span(start: number, end: number): RegExpSpan {\n return { end, start };\n}\n\nfunction fail(\n kind: RegExpErrorKind,\n message: string,\n location: RegExpSpan,\n section: RegExpErrorSection = \"pattern\",\n): never {\n throw new PatternFailure({ kind, message, section, span: location });\n}\n\n/**\n * Describe a construct that only Annex B admits, for a parse that reached\n * it without Annex B's grammar.\n *\n * Under `u` or `v` Annex B never applied, so the rejection is the early\n * error the edition itself requires and reports as invalid text. Without\n * them the text is one a web browser accepts, and only a caller that asked\n * for the core grammar alone gets here, so the rejection names Annex B as\n * an `unsupported` construct rather than as a defect.\n */\nfunction annexBMessage(subject: string): string {\n const tail = \"is admitted only by Annex B, which this parse excludes.\";\n return `${subject} ${tail}`;\n}\n\nfunction annexBError(\n state: ParseState,\n invalidMessage: string,\n subject: string,\n location: RegExpSpan,\n): RegExpPatternError {\n return state.unicodeMode\n ? {\n kind: \"invalid\",\n message: invalidMessage,\n section: \"pattern\",\n span: location,\n }\n : {\n kind: \"unsupported\",\n message: annexBMessage(subject),\n section: \"pattern\",\n span: location,\n };\n}\n\n/** Reject a construct that only Annex B admits, keeping its span. */\nfunction refuseAnnexB(\n state: ParseState,\n invalidMessage: string,\n subject: string,\n location: RegExpSpan,\n): never {\n throw new PatternFailure(\n annexBError(state, invalidMessage, subject, location),\n );\n}\n\nfunction admits(state: ParseState, point: RegExpExtensionPoint): boolean {\n return state.extensions.admitted.includes(point);\n}\n\nfunction at(state: ParseState, offset: number): string | undefined {\n return state.source[state.index + offset];\n}\n\nfunction done(state: ParseState): boolean {\n return state.index >= state.source.length;\n}\n\nfunction eat(state: ParseState, text: string): boolean {\n if (!state.source.startsWith(text, state.index)) return false;\n state.index += text.length;\n return true;\n}\n\n/**\n * Read one source character.\n *\n * A pattern is a sequence of code points under `u` or `v` and a sequence\n * of UTF-16 code units otherwise, which is the only place the flag set\n * changes how text is consumed rather than what it means.\n */\nfunction readCharacter(state: ParseState): RegExpCharacter {\n const start = state.index;\n const unit = state.source.charCodeAt(start);\n const value = state.unicodeMode\n ? (state.source.codePointAt(start) ?? 0)\n : Number.isNaN(unit)\n ? 0\n : unit;\n state.index += value > 0xffff ? 2 : 1;\n return { kind: \"character\", span: span(start, state.index), value };\n}\n\nfunction isDecimalDigit(character: string | undefined): boolean {\n return character != null && character >= \"0\" && character <= \"9\";\n}\n\nfunction isHexDigit(character: string | undefined): boolean {\n if (character == null) return false;\n return (\n (character >= \"0\" && character <= \"9\") ||\n (character >= \"a\" && character <= \"f\") ||\n (character >= \"A\" && character <= \"F\")\n );\n}\n\nfunction readDecimalDigits(state: ParseState): string {\n const start = state.index;\n while (isDecimalDigit(at(state, 0))) state.index += 1;\n return state.source.slice(start, state.index);\n}\n\n/**\n * Whether one code point has the Unicode `ID_Start` or `ID_Continue`\n * property.\n *\n * The compiler core links no Unicode data, so ASCII is decided here and\n * anything else is delegated to the caller. Without a classifier a\n * non-ASCII code point is refused rather than guessed, which keeps an\n * unadmitted name out of the accepted grammar instead of admitting one\n * whose validity was never checked. The two properties are exactly what\n * the grammar names: the `$`, `_`, and zero-width joiner allowances of an\n * identifier belong to the caller of this predicate, not to it.\n */\nfunction identifierProperty(\n state: ParseState,\n codePoint: number,\n position: \"continue\" | \"start\",\n subject: string,\n location: RegExpSpan,\n): boolean {\n if (codePoint < 0x80) {\n const character = String.fromCharCode(codePoint);\n if (character >= \"a\" && character <= \"z\") return true;\n if (character >= \"A\" && character <= \"Z\") return true;\n if (position === \"start\") return false;\n return (character >= \"0\" && character <= \"9\") || character === \"_\";\n }\n const classify =\n position === \"start\"\n ? state.extensions.identifierStart\n : state.extensions.identifierPart;\n if (classify == null) {\n fail(\n \"unsupported\",\n `${subject} outside ASCII needs Unicode identifier data ` +\n \"that is not linked.\",\n location,\n );\n }\n return classify(codePoint);\n}\n\nfunction readHexValue(state: ParseState, digits: number): number {\n const start = state.index;\n for (let offset = 0; offset < digits; offset += 1) {\n if (!isHexDigit(at(state, offset))) return -1;\n }\n state.index += digits;\n return Number.parseInt(state.source.slice(start, state.index), 16);\n}\n\n/**\n * Read one `\\u` escape after its `u`.\n *\n * `unicodeSyntax` selects the RegExpUnicodeEscapeSequence grammar\n * parameter. Only the unicode form admits a braced code point and joins a\n * lead surrogate escape to a following trail surrogate escape, which is\n * what makes an escaped supplementary code point equal to a written one.\n * Without it the same text is two independent code units. A group name\n * always uses the unicode form, whatever the flag set says.\n */\nfunction readUnicodeEscape(\n state: ParseState,\n unicodeSyntax: boolean,\n start: number,\n): number {\n if (unicodeSyntax && at(state, 0) === \"{\") {\n state.index += 1;\n const digitStart = state.index;\n while (isHexDigit(at(state, 0))) state.index += 1;\n if (state.index === digitStart || at(state, 0) !== \"}\") {\n fail(\"invalid\", \"A braced Unicode escape is incomplete.\", {\n end: state.index,\n start,\n });\n }\n const value = Number.parseInt(\n state.source.slice(digitStart, state.index),\n 16,\n );\n state.index += 1;\n if (value > 0x10_ffff) {\n fail(\"invalid\", \"A Unicode escape is above the code point range.\", {\n end: state.index,\n start,\n });\n }\n return value;\n }\n const value = readHexValue(state, 4);\n if (value < 0) {\n // A group name always uses the unicode form, so only a character\n // escape in a pattern without `u` or `v` reaches Annex B's identity\n // escape here. It names the `u` alone and leaves what follows to the\n // next term, which is how `\\u{2}` repeats a `u` without the flag.\n const location = { end: state.index, start };\n const message = \"A Unicode escape needs four hexadecimal digits.\";\n if (unicodeSyntax) fail(\"invalid\", message, location);\n if (state.annexB) return 0x75;\n refuseAnnexB(state, message, \"An incomplete Unicode escape\", location);\n }\n if (\n unicodeSyntax &&\n value >= 0xd800 &&\n value <= 0xdbff &&\n state.source.startsWith(\"\\\\u\", state.index)\n ) {\n const resume = state.index;\n state.index += 2;\n const trail = readHexValue(state, 4);\n if (trail >= 0xdc00 && trail <= 0xdfff) {\n return (value - 0xd800) * 0x400 + (trail - 0xdc00) + 0x1_0000;\n }\n state.index = resume;\n }\n return value;\n}\n\n/** Whether one character is an OctalDigit. */\nfunction isOctalDigit(character: string | undefined): boolean {\n return character != null && character >= \"0\" && character <= \"7\";\n}\n\n/**\n * Read one LegacyOctalEscapeSequence at its first digit.\n *\n * The grammar takes three digits only when the first is at most 3, so the\n * value never exceeds 0o377, and it takes the longest sequence its\n * lookahead restrictions allow: `\\47` is one escape and `\\477` is that\n * escape followed by a `7`.\n */\nfunction readLegacyOctalEscape(state: ParseState): number {\n const first = at(state, 0) ?? \"0\";\n let value = Number(first);\n state.index += 1;\n if (!isOctalDigit(at(state, 0))) return value;\n value = value * 8 + Number(at(state, 0));\n state.index += 1;\n if (first > \"3\" || !isOctalDigit(at(state, 0))) return value;\n value = value * 8 + Number(at(state, 0));\n state.index += 1;\n return value;\n}\n\n/**\n * Read one character escape after its backslash and return a code point.\n *\n * Without Annex B's grammar, a legacy octal escape and an identity escape\n * over an identifier character are rejected rather than accepted for a\n * pattern without `u` or `v`. With it, `inClass` decides how `\\c` without\n * an ASCII letter reads: a class admits a decimal digit or `_` as its\n * control letter, and otherwise the backslash is a character of its own\n * and the `c` stays for the next atom.\n */\nfunction readCharacterEscape(\n state: ParseState,\n start: number,\n inClass: boolean,\n): number {\n const character = at(state, 0);\n if (character == null) {\n fail(\"invalid\", \"A pattern cannot end with a backslash.\", {\n end: state.index,\n start,\n });\n }\n const control = controlEscapes.get(character);\n if (control != null) {\n state.index += 1;\n return control;\n }\n if (character === \"c\") {\n const letter = at(state, 1);\n if (\n letter == null ||\n !((letter >= \"a\" && letter <= \"z\") || (letter >= \"A\" && letter <= \"Z\"))\n ) {\n if (state.annexB) {\n if (inClass && (isDecimalDigit(letter) || letter === \"_\")) {\n state.index += 2;\n return (letter?.charCodeAt(0) ?? 0) % 32;\n }\n return 0x5c;\n }\n refuseAnnexB(\n state,\n \"A control escape needs an ASCII letter.\",\n \"A control escape without an ASCII letter\",\n { end: state.index + 1, start },\n );\n }\n state.index += 2;\n return letter.charCodeAt(0) % 32;\n }\n if (state.annexB && isOctalDigit(character)) {\n return readLegacyOctalEscape(state);\n }\n if (character === \"0\") {\n if (isDecimalDigit(at(state, 1))) {\n refuseAnnexB(\n state,\n \"A legacy octal escape is outside the candidate edition.\",\n \"A legacy octal escape\",\n { end: state.index + 2, start },\n );\n }\n state.index += 1;\n return 0;\n }\n if (character === \"x\") {\n state.index += 1;\n const value = readHexValue(state, 2);\n if (value < 0) {\n if (state.annexB) return 0x78;\n refuseAnnexB(\n state,\n \"A hexadecimal escape needs two hexadecimal digits.\",\n \"An incomplete hexadecimal escape\",\n { end: state.index, start },\n );\n }\n return value;\n }\n if (character === \"u\") {\n state.index += 1;\n return readUnicodeEscape(state, state.unicodeMode, start);\n }\n const escaped = readCharacter(state);\n if (state.unicodeMode) {\n const text = String.fromCodePoint(escaped.value);\n if (!syntaxCharacters.has(text) && text !== \"/\") {\n fail(\"invalid\", \"This identity escape is not allowed.\", {\n end: state.index,\n start,\n });\n }\n return escaped.value;\n }\n const location = { end: state.index, start };\n if (escaped.value === 0x6b && state.groupNameDeclared) {\n fail(\"invalid\", \"This identity escape is not allowed.\", location);\n }\n // Annex B's identity escape admits every source character but `c`, and\n // `k` once the pattern declares a group name, both decided above.\n if (state.annexB) return escaped.value;\n if (\n identifierProperty(\n state,\n escaped.value,\n \"continue\",\n \"An identity escape\",\n location,\n )\n ) {\n refuseAnnexB(\n state,\n \"This identity escape is not allowed.\",\n \"This identity escape\",\n location,\n );\n }\n return escaped.value;\n}\n\n/**\n * The six CharacterClassEscape spellings, keyed by exact letter.\n *\n * The uppercase spelling of each is its complement, and no other letter\n * names a class escape, so the table is matched literally rather than\n * through a case conversion that another letter could reach.\n */\nconst classEscapeSets = new Map<\n string,\n { readonly negated: boolean; readonly set: RegExpClassEscapeSet }\n>([\n [\"D\", { negated: true, set: \"digit\" }],\n [\"S\", { negated: true, set: \"space\" }],\n [\"W\", { negated: true, set: \"word\" }],\n [\"d\", { negated: false, set: \"digit\" }],\n [\"s\", { negated: false, set: \"space\" }],\n [\"w\", { negated: false, set: \"word\" }],\n]);\n\nfunction readClassEscape(\n state: ParseState,\n start: number,\n): RegExpClassEscape | undefined {\n const character = at(state, 0);\n const selected =\n character == null ? undefined : classEscapeSets.get(character);\n if (selected == null) return undefined;\n state.index += 1;\n return {\n kind: \"class-escape\",\n negated: selected.negated,\n set: selected.set,\n span: span(start, state.index),\n };\n}\n\n/**\n * Whether one text is a UnicodePropertyName.\n *\n * The grammar spells a name with ASCII letters and low lines and a value\n * with those and decimal digits, so a name is checked here rather than\n * left to whichever unit resolves it against Unicode data.\n */\nfunction propertyNameCharacters(text: string): boolean {\n return text.length > 0 && /^[A-Za-z_]+$/u.test(text);\n}\n\n/** Whether one text is a UnicodePropertyValue or a lone name or value. */\nfunction propertyValueCharacters(text: string): boolean {\n return text.length > 0 && /^[A-Za-z_0-9]+$/u.test(text);\n}\n\n/**\n * Read one `\\p` or `\\P` escape after its backslash.\n *\n * The escape only exists under `u` and `v`; elsewhere `p` is an\n * identifier character, so the backslash form is an invalid identity\n * escape rather than a property reference. A property name is an early\n * error unless a caller both admits the point and resolves the name, so\n * an unresolvable name is never accepted for lack of a resolver.\n */\nfunction readUnicodePropertyEscape(\n state: ParseState,\n start: number,\n): RegExpUnicodePropertyEscape | undefined {\n const character = at(state, 0);\n if (!state.unicodeMode || (character !== \"p\" && character !== \"P\")) {\n return undefined;\n }\n state.index += 1;\n if (!eat(state, \"{\")) {\n fail(\"invalid\", \"A Unicode property escape needs a braced name.\", {\n end: state.index,\n start,\n });\n }\n const nameStart = state.index;\n while (!done(state) && at(state, 0) !== \"}\" && at(state, 0) !== \"=\") {\n state.index += 1;\n }\n const first = state.source.slice(nameStart, state.index);\n let second: string | undefined;\n if (at(state, 0) === \"=\") {\n state.index += 1;\n const valueStart = state.index;\n while (!done(state) && at(state, 0) !== \"}\") state.index += 1;\n second = state.source.slice(valueStart, state.index);\n }\n if (!eat(state, \"}\")) {\n fail(\"invalid\", \"A Unicode property escape is unterminated.\", {\n end: state.index,\n start,\n });\n }\n const location = span(start, state.index);\n const named =\n second == null\n ? propertyValueCharacters(first)\n : propertyNameCharacters(first) && propertyValueCharacters(second);\n if (!named) {\n fail(\"invalid\", \"A Unicode property escape names nothing valid.\", location);\n }\n if (!admits(state, \"unicode-property-escapes\")) {\n fail(\n \"unsupported\",\n \"A Unicode property escape is not admitted yet.\",\n location,\n );\n }\n const resolve = state.extensions.unicodeProperty;\n if (resolve == null) {\n fail(\n \"unsupported\",\n \"A Unicode property escape needs property data that is not linked.\",\n location,\n );\n }\n const escape: RegExpUnicodePropertyEscape = {\n kind: \"unicode-property\",\n negated: character === \"P\",\n property: first,\n span: location,\n ...includePropertiesWhen(() => {\n if (second == null) return undefined;\n return { value: second };\n }),\n };\n if (\n !state.flags.unicodeSets &&\n escape.value == null &&\n unicodeStringProperties.has(escape.property)\n ) {\n fail(\n \"invalid\",\n \"A Unicode property of strings requires the v flag.\",\n location,\n );\n }\n if (!resolve(escape)) {\n if (\n state.flags.unicodeSets &&\n !escape.negated &&\n escape.value == null &&\n unicodeStringProperties.has(escape.property)\n ) {\n fail(\n \"unsupported\",\n \"A Unicode property of strings is not admitted yet.\",\n location,\n );\n }\n fail(\"invalid\", \"This Unicode property is not defined.\", location);\n }\n return escape;\n}\n\n/**\n * Count the left-capturing parentheses in a pattern text.\n *\n * This is CountLeftCapturingParensWithin over the whole pattern, which\n * Annex B needs before the parse reaches the groups. The scan skips an\n * escape and the inside of a character class, and it counts `(?<` only\n * when a group name rather than a lookbehind introducer follows. A text\n * the parse later rejects may count differently, but then no reading of\n * its escapes is ever returned.\n */\nfunction countCapturingGroups(source: string): number {\n let count = 0;\n let insideClass = false;\n for (let index = 0; index < source.length; index += 1) {\n const character = source[index];\n if (character === \"\\\\\") {\n index += 1;\n continue;\n }\n if (insideClass) {\n if (character === \"]\") insideClass = false;\n continue;\n }\n if (character === \"[\") {\n insideClass = true;\n continue;\n }\n if (character !== \"(\") continue;\n if (source[index + 1] !== \"?\") {\n count += 1;\n continue;\n }\n if (source[index + 2] !== \"<\") continue;\n const next = source[index + 3];\n if (next !== \"=\" && next !== \"!\") count += 1;\n }\n return count;\n}\n\n/**\n * Whether the pattern text holds a GroupSpecifier.\n *\n * The scan skips an escape and the inside of a character class, where\n * `(?<` is ordinary text rather than an introducer, and it excludes the\n * two lookbehind introducers that share the first three characters.\n */\nfunction scanForGroupName(source: string): boolean {\n let insideClass = false;\n for (let index = 0; index < source.length; index += 1) {\n const character = source[index];\n if (character === \"\\\\\") {\n index += 1;\n continue;\n }\n if (insideClass) {\n if (character === \"]\") insideClass = false;\n continue;\n }\n if (character === \"[\") {\n insideClass = true;\n continue;\n }\n if (character !== \"(\") continue;\n if (source[index + 1] !== \"?\" || source[index + 2] !== \"<\") continue;\n const next = source[index + 3];\n if (next !== \"=\" && next !== \"!\") return true;\n }\n return false;\n}\n\n/**\n * Read one `<name>` group specifier after its introducer.\n *\n * Both spellings that reach this reader parse with the grammar's\n * named-reference production active: a declaration is a group specifier\n * by construction, and a `\\k` reference reaches it only where the pattern\n * declares a group name or carries `u` or `v`. A malformed name is\n * therefore the edition's own early error rather than an Annex B\n * boundary.\n */\nfunction readGroupName(state: ParseState, start: number): string {\n if (!eat(state, \"<\")) {\n fail(\"invalid\", \"A group name must be enclosed in angle brackets.\", {\n end: state.index,\n start,\n });\n }\n let name = \"\";\n while (!done(state) && at(state, 0) !== \">\") {\n const characterStart = state.index;\n let codePoint: number;\n if (eat(state, \"\\\\\")) {\n if (!eat(state, \"u\")) {\n fail(\"invalid\", \"A group name escape must be a Unicode escape.\", {\n end: state.index,\n start: characterStart,\n });\n }\n codePoint = readUnicodeEscape(state, true, characterStart);\n } else {\n const start2 = state.index;\n codePoint = state.source.codePointAt(start2) ?? 0;\n state.index += codePoint > 0xffff ? 2 : 1;\n }\n const location = span(characterStart, state.index);\n const dollarOrLow = codePoint === 0x24 || codePoint === 0x5f;\n const admitted =\n name.length === 0\n ? dollarOrLow ||\n identifierProperty(\n state,\n codePoint,\n \"start\",\n \"A group name\",\n location,\n )\n : dollarOrLow ||\n codePoint === 0x200c ||\n codePoint === 0x200d ||\n identifierProperty(\n state,\n codePoint,\n \"continue\",\n \"A group name\",\n location,\n );\n if (!admitted) {\n fail(\n \"invalid\",\n \"This character is not allowed in a group name.\",\n location,\n );\n }\n name += String.fromCodePoint(codePoint);\n }\n if (name.length === 0 || !eat(state, \">\")) {\n fail(\"invalid\", \"A group name is incomplete.\", {\n end: state.index,\n start,\n });\n }\n return name;\n}\n\nfunction readModifierFlags(\n state: ParseState,\n start: number,\n): RegExpModifierFlag[] {\n const selected: RegExpModifierFlag[] = [];\n while (!done(state)) {\n const character = at(state, 0);\n if (character == null || !modifierFlags.has(character)) break;\n // SAFETY: Membership in modifierFlags establishes the modifier domain.\n if (selected.includes(character as RegExpModifierFlag)) {\n fail(\"invalid\", \"A modifier group repeats a flag.\", {\n end: state.index + 1,\n start,\n });\n }\n // SAFETY: Membership in modifierFlags establishes the modifier domain.\n selected.push(character as RegExpModifierFlag);\n state.index += 1;\n }\n return selected;\n}\n\nfunction classItemValue(item: RegExpClassItem): RegExpCharacter | undefined {\n return item.kind === \"character\" ? item : undefined;\n}\n\nfunction parseClassStringDisjunction(\n state: ParseState,\n): RegExpClassStringDisjunction {\n const start = state.index;\n state.index += 3;\n const strings: RegExpCharacter[][] = [];\n let characters: RegExpCharacter[] = [];\n for (;;) {\n if (done(state)) {\n fail(\"invalid\", \"A class string disjunction is unterminated.\", {\n end: state.index,\n start,\n });\n }\n if (eat(state, \"|\")) {\n strings.push(characters);\n characters = [];\n continue;\n }\n if (eat(state, \"}\")) {\n strings.push(characters);\n break;\n }\n const characterStart = state.index;\n let value: number;\n if (eat(state, \"\\\\\")) {\n if (eat(state, \"b\")) {\n value = 0x08;\n } else {\n value = readClassSetCharacterEscape(state, characterStart);\n }\n } else {\n validateClassSetCharacter(state);\n value = readCharacter(state).value;\n }\n characters.push({\n kind: \"character\",\n span: span(characterStart, state.index),\n value,\n });\n }\n return {\n kind: \"class-strings\",\n span: span(start, state.index),\n strings,\n };\n}\n\nfunction validateClassSetCharacter(state: ParseState): void {\n const firstCharacter = at(state, 0);\n if (\n firstCharacter == null ||\n firstCharacter === \"]\" ||\n state.source.startsWith(\"&&\", state.index) ||\n state.source.startsWith(\"--\", state.index)\n ) {\n fail(\n \"invalid\",\n \"A class set operator needs an operand.\",\n span(state.index, Math.min(state.index + 2, state.source.length)),\n );\n }\n if (classSetSyntaxCharacters.has(firstCharacter)) {\n fail(\n \"invalid\",\n \"A class set syntax character must be escaped.\",\n span(state.index, state.index + 1),\n );\n }\n if (\n firstCharacter === at(state, 1) &&\n classSetReservedDoublePunctuators.has(firstCharacter)\n ) {\n fail(\n \"invalid\",\n \"A doubled class set punctuator must be escaped.\",\n span(state.index, state.index + 2),\n );\n }\n}\n\nfunction parseClassSetOperand(state: ParseState): RegExpClassSetOperand {\n if (at(state, 0) === \"[\") return parseUnicodeClassSet(state);\n if (state.source.startsWith(\"\\\\q{\", state.index)) {\n return parseClassStringDisjunction(state);\n }\n validateClassSetCharacter(state);\n const first = parseClassAtom(state);\n if (\n first.kind === \"character\" &&\n at(state, 0) === \"-\" &&\n at(state, 1) !== \"-\" &&\n at(state, 1) !== \"]\" &&\n at(state, 1) != null\n ) {\n state.index += 1;\n if (at(state, 0) === \"[\") {\n fail(\n \"invalid\",\n \"A nested class set cannot be a range bound.\",\n span(first.span.start, state.index + 1),\n );\n }\n validateClassSetCharacter(state);\n const second = parseClassAtom(state);\n if (second.kind !== \"character\" || first.value > second.value) {\n fail(\"invalid\", \"A character class range is invalid.\", {\n end: state.index,\n start: first.span.start,\n });\n }\n return {\n end: second,\n kind: \"range\",\n span: span(first.span.start, state.index),\n start: first,\n };\n }\n return first;\n}\n\nfunction classSetOperandMayContainStrings(\n operand: RegExpClassSetOperand,\n): boolean {\n if (operand.kind === \"class-strings\") {\n return operand.strings.some((characters) => characters.length !== 1);\n }\n if (operand.kind === \"unicode-property\") {\n return (\n !operand.negated &&\n operand.value == null &&\n unicodeStringProperties.has(operand.property)\n );\n }\n if (operand.kind !== \"class-set\") return false;\n if (operand.operation === \"union\") {\n return operand.operands.some(classSetOperandMayContainStrings);\n }\n if (operand.operation === \"intersection\") {\n return (\n operand.operands.length > 0 &&\n operand.operands.every(classSetOperandMayContainStrings)\n );\n }\n const first = operand.operands[0];\n return first != null && classSetOperandMayContainStrings(first);\n}\n\n/**\n * Parse one `v`-mode class set, charging the reviewed nesting budget.\n *\n * A nested class is an operand of its enclosing class, so this production\n * recurses through `parseClassSetOperand` exactly as a group recurses\n * through `parseDisjunction`. It shares the one `nestingDepth` budget so a\n * pattern that nests either way, or both at once, reports the owned located\n * `limit` error rather than exhausting the host stack.\n */\nfunction parseUnicodeClassSet(state: ParseState): RegExpUnicodeClassSet {\n const start = state.index;\n state.depth += 1;\n if (state.depth > state.limits.nestingDepth) {\n fail(\"limit\", \"A pattern nests above the reviewed depth limit.\", {\n end: state.index,\n start,\n });\n }\n state.index += 1;\n const negated = eat(state, \"^\");\n const operands: RegExpClassSetOperand[] = [];\n if (at(state, 0) !== \"]\") operands.push(parseClassSetOperand(state));\n let operation: RegExpUnicodeClassSet[\"operation\"] = \"union\";\n if (state.source.startsWith(\"&&\", state.index)) {\n operation = \"intersection\";\n } else if (state.source.startsWith(\"--\", state.index)) {\n operation = \"subtraction\";\n }\n if (operation !== \"union\" && operands[0]?.kind === \"range\") {\n fail(\n \"invalid\",\n \"A class set range cannot be an intersection or subtraction operand.\",\n operands[0].span,\n );\n }\n while (!done(state) && at(state, 0) !== \"]\") {\n if (operation === \"intersection\") {\n if (!state.source.startsWith(\"&&\", state.index)) {\n fail(\"invalid\", \"A class set mixes its operators.\", {\n end: state.index + 1,\n start: state.index,\n });\n }\n state.index += 2;\n if (at(state, 0) === \"&\") {\n fail(\n \"invalid\",\n \"A class set operator needs an operand.\",\n span(state.index - 2, state.index + 1),\n );\n }\n } else if (operation === \"subtraction\") {\n if (!state.source.startsWith(\"--\", state.index)) {\n fail(\"invalid\", \"A class set mixes its operators.\", {\n end: state.index + 1,\n start: state.index,\n });\n }\n state.index += 2;\n }\n const operand = parseClassSetOperand(state);\n if (operation !== \"union\" && operand.kind === \"range\") {\n fail(\n \"invalid\",\n \"A class set range cannot be an intersection or subtraction \" +\n \"operand.\",\n operand.span,\n );\n }\n operands.push(operand);\n }\n if (!eat(state, \"]\")) {\n fail(\"invalid\", \"A character class is unterminated.\", {\n end: state.index,\n start,\n });\n }\n const classSet: RegExpUnicodeClassSet = {\n kind: \"class-set\",\n negated,\n operands,\n operation,\n span: span(start, state.index),\n };\n if (negated && classSetOperandMayContainStrings(classSet)) {\n fail(\n \"invalid\",\n \"A negated character class may contain strings.\",\n classSet.span,\n );\n }\n state.depth -= 1;\n return classSet;\n}\n\nfunction parseCharacterClass(\n state: ParseState,\n): RegExpCharacterClass | RegExpUnicodeClassSet {\n const start = state.index;\n if (state.flags.unicodeSets) {\n if (!admits(state, \"class-set-notation\")) {\n fail(\n \"unsupported\",\n \"Class set notation is not admitted yet.\",\n span(start, start + 1),\n );\n }\n return parseUnicodeClassSet(state);\n }\n state.index += 1;\n const negated = eat(state, \"^\");\n const items: RegExpClassItem[] = [];\n for (;;) {\n if (done(state)) {\n fail(\"invalid\", \"A character class is unterminated.\", {\n end: state.index,\n start,\n });\n }\n if (eat(state, \"]\")) break;\n const first = parseClassAtom(state);\n if (at(state, 0) === \"-\" && at(state, 1) !== \"]\" && at(state, 1) != null) {\n const dash = state.index;\n state.index += 1;\n const second = parseClassAtom(state);\n const low = classItemValue(first);\n const high = classItemValue(second);\n if ((low == null || high == null) && state.annexB) {\n // Annex B's CharacterRangeOrUnion: a class escape at either end\n // makes the three atoms a union that includes the dash itself.\n items.push(\n first,\n { kind: \"character\", span: span(dash, dash + 1), value: 0x2d },\n second,\n );\n continue;\n }\n if (low == null || high == null) {\n refuseAnnexB(\n state,\n \"A character class range bound cannot be a class escape.\",\n \"A class escape as a character class range bound\",\n { end: state.index, start: first.span.start },\n );\n }\n if (low.value > high.value) {\n fail(\"invalid\", \"A character class range is out of order.\", {\n end: state.index,\n start: first.span.start,\n });\n }\n items.push({\n end: high,\n kind: \"range\",\n span: span(first.span.start, state.index),\n start: low,\n });\n continue;\n }\n items.push(first);\n }\n return {\n items,\n kind: \"character-class\",\n negated,\n span: span(start, state.index),\n };\n}\n\nfunction parseClassAtom(state: ParseState): RegExpClassItem {\n const start = state.index;\n if (!eat(state, \"\\\\\")) return readCharacter(state);\n if (at(state, 0) === \"b\") {\n state.index += 1;\n return { kind: \"character\", span: span(start, state.index), value: 8 };\n }\n const classEscape = readClassEscape(state, start);\n if (classEscape != null) return classEscape;\n const property = readUnicodePropertyEscape(state, start);\n if (property != null) return property;\n return {\n kind: \"character\",\n span: span(start, state.index),\n value: readClassSetCharacterEscape(state, start),\n };\n}\n\nfunction parseAtomEscape(state: ParseState, start: number): RegExpAtom {\n const character = at(state, 0);\n if (character != null && character >= \"1\" && character <= \"9\") {\n const digitStart = state.index;\n const digits = readDecimalDigits(state);\n const location = span(start, state.index);\n if (state.annexB && Number(digits) > state.captureCount) {\n /*\n * Annex B admits a DecimalEscape only up to the pattern's capture\n * count. Past it the same text is a legacy octal escape, or an\n * identity escape when it starts with 8 or 9, and the digits that\n * escape does not take are pattern characters.\n */\n state.index = digitStart;\n if (character >= \"8\") {\n state.index += 1;\n return {\n kind: \"character\",\n span: span(start, state.index),\n value: character.charCodeAt(0),\n };\n }\n const value = readLegacyOctalEscape(state);\n return { kind: \"character\", span: span(start, state.index), value };\n }\n /*\n * A pattern cannot declare more groups than its own text is long, so\n * an index too large to represent exactly still names no group. The\n * approximate value is only ever compared against the capture count,\n * and validation reports the ordinary early error for it.\n */\n const index = Number(digits);\n state.backreferences.push({ index, span: location });\n return { index, kind: \"backreference\", span: location };\n }\n if (character === \"k\") {\n state.index += 1;\n /*\n * Without a group specifier and without `u` or `v` the grammar never\n * enters its named-reference production, so Annex B reads the escape\n * as an identity escape whatever follows it. Reading a group name\n * here instead would report the shape of text the grammar never\n * looked at.\n */\n if (!state.unicodeMode && !state.groupNameDeclared) {\n if (state.annexB) {\n return {\n kind: \"character\",\n span: span(start, state.index),\n value: 0x6b,\n };\n }\n fail(\n \"unsupported\",\n annexBMessage(\n \"A named backreference in a pattern that declares no group name\",\n ),\n span(start, state.index),\n );\n }\n const name = readGroupName(state, start);\n const location = span(start, state.index);\n state.namedReferences.push({ name, span: location });\n const indices = state.namedReferenceIndices.get(name) ?? [];\n state.namedReferenceIndices.set(name, indices);\n return { indices, kind: \"named-backreference\", name, span: location };\n }\n const classEscape = readClassEscape(state, start);\n if (classEscape != null) return classEscape;\n const property = readUnicodePropertyEscape(state, start);\n if (property != null) return property;\n return {\n kind: \"character\",\n span: span(start, state.index),\n value: readCharacterEscape(state, start, false),\n };\n}\n\nfunction parseGroup(state: ParseState): RegExpAtom {\n const start = state.index;\n state.index += 1;\n if (eat(state, \"?\")) {\n if (eat(state, \":\")) {\n const body = parseDisjunction(state);\n expectGroupEnd(state, start);\n return { body, kind: \"group\", span: span(start, state.index) };\n }\n if (at(state, 0) === \"<\") {\n const name = readGroupName(state, start);\n const capture = declareCapture(state, start, name);\n const body = parseDisjunction(state);\n expectGroupEnd(state, start);\n return {\n body,\n index: capture,\n kind: \"capturing-group\",\n name,\n span: span(start, state.index),\n };\n }\n const enabled = readModifierFlags(state, start);\n const disabled = eat(state, \"-\") ? readModifierFlags(state, start) : [];\n if (!eat(state, \":\")) {\n fail(\"invalid\", \"This group prefix is not a valid group.\", {\n end: state.index + 1,\n start,\n });\n }\n if (enabled.length === 0 && disabled.length === 0) {\n fail(\"invalid\", \"A modifier group names no flag.\", {\n end: state.index,\n start,\n });\n }\n if (enabled.some((flag) => disabled.includes(flag))) {\n fail(\"invalid\", \"A modifier group both adds and removes a flag.\", {\n end: state.index,\n start,\n });\n }\n if (!admits(state, \"modifiers\")) {\n fail(\"unsupported\", \"An inline modifier group is not admitted yet.\", {\n end: state.index,\n start,\n });\n }\n const body = parseDisjunction(state);\n expectGroupEnd(state, start);\n return {\n body,\n disabled,\n enabled,\n kind: \"modifier-group\",\n span: span(start, state.index),\n };\n }\n const capture = declareCapture(state, start);\n const body = parseDisjunction(state);\n expectGroupEnd(state, start);\n return {\n body,\n index: capture,\n kind: \"capturing-group\",\n span: span(start, state.index),\n };\n}\n\nfunction declareCapture(\n state: ParseState,\n start: number,\n name?: string,\n): number {\n if (state.captures.length >= state.limits.capturingGroups) {\n fail(\"limit\", \"A pattern declares too many capturing groups.\", {\n end: state.index,\n start,\n });\n }\n const index = state.captures.length + 1;\n const location = span(start, state.index);\n state.captures.push({\n index,\n span: location,\n ...includePropertiesWhen(() => {\n if (name == null) return undefined;\n return { name };\n }),\n });\n if (name != null) {\n state.namedGroups.push({\n name,\n path: [...state.path],\n span: location,\n });\n }\n return index;\n}\n\nfunction expectGroupEnd(state: ParseState, start: number): void {\n if (!eat(state, \")\")) {\n fail(\"invalid\", \"A group is unterminated.\", { end: state.index, start });\n }\n}\n\nfunction parseAtom(state: ParseState): RegExpAtom {\n const start = state.index;\n const character = at(state, 0);\n if (character === \".\") {\n state.index += 1;\n return { kind: \"dot\", span: span(start, state.index) };\n }\n if (character === \"(\") return parseGroup(state);\n if (character === \"[\") return parseCharacterClass(state);\n if (character === \"\\\\\") {\n state.index += 1;\n return parseAtomEscape(state, start);\n }\n if (character === \"*\" || character === \"+\" || character === \"?\") {\n fail(\"invalid\", \"A quantifier has no atom to repeat.\", {\n end: start + 1,\n start,\n });\n }\n if (character === \"{\") {\n if (bracedQuantifierFollows(state)) {\n fail(\"invalid\", \"A quantifier has no atom to repeat.\", {\n end: start + 1,\n start,\n });\n }\n if (state.annexB) return readCharacter(state);\n refuseAnnexB(\n state,\n \"An unescaped brace is not a pattern character.\",\n \"An unescaped brace\",\n { end: start + 1, start },\n );\n }\n if ((character === \"]\" || character === \"}\") && !state.annexB) {\n refuseAnnexB(\n state,\n \"This character must be escaped.\",\n \"This unescaped character\",\n { end: start + 1, start },\n );\n }\n return readCharacter(state);\n}\n\n/**\n * The bounds one braced quantifier spells, before validation.\n *\n * The digits are retained because two bounds can round to one double\n * while their written values differ, and the edition compares the exact\n * mathematical values.\n */\ninterface QuantifierBounds {\n readonly maximum: number;\n readonly maximumDigits?: string;\n readonly minimum: number;\n readonly minimumDigits: string;\n}\n\n/** Compare two decimal digit strings by exact mathematical value. */\nfunction compareDecimalDigits(first: string, second: string): number {\n const left = first.replace(/^0+(?=\\d)/u, \"\");\n const right = second.replace(/^0+(?=\\d)/u, \"\");\n if (left.length !== right.length) return left.length - right.length;\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\n/**\n * Read a braced quantifier body after its `{`, or return undefined when\n * the text is not one. Annex B is outside the claim, so a `{` that starts\n * no quantifier is an error at the caller rather than a literal brace.\n *\n * Recognition is separate from validation: a quantifier that no atom\n * precedes is an error whatever its bounds say, so the bound order and\n * the reviewed bound limit are checked only where a quantifier is\n * grammatically admitted.\n */\nfunction readBracedQuantifier(state: ParseState): QuantifierBounds | undefined {\n const minimumDigits = readDecimalDigits(state);\n if (minimumDigits.length === 0) return undefined;\n const minimum = Number(minimumDigits);\n let maximum = minimum;\n let maximumDigits: string | undefined = minimumDigits;\n if (eat(state, \",\")) {\n const written = readDecimalDigits(state);\n maximumDigits = written.length === 0 ? undefined : written;\n maximum =\n maximumDigits == null ? Number.POSITIVE_INFINITY : Number(written);\n }\n if (!eat(state, \"}\")) return undefined;\n return {\n maximum,\n ...includePropertiesWhen(() => {\n if (maximumDigits == null) return undefined;\n return {\n maximumDigits,\n };\n }),\n minimum,\n minimumDigits,\n };\n}\n\nfunction validateQuantifierBounds(\n state: ParseState,\n bounds: QuantifierBounds,\n start: number,\n): QuantifierBounds {\n const location = { end: state.index, start };\n /*\n * The early error comes first: a quantifier whose written lower bound\n * exceeds its written upper bound is invalid at every limit, and the\n * exact digits decide it because two bounds can share one double.\n */\n if (\n bounds.maximumDigits != null &&\n compareDecimalDigits(bounds.minimumDigits, bounds.maximumDigits) > 0\n ) {\n fail(\n \"invalid\",\n \"A quantifier's lower bound is above its upper bound.\",\n location,\n );\n }\n const limit = String(state.limits.quantifierBound);\n const above = (digits: string): boolean =>\n compareDecimalDigits(digits, limit) > 0;\n if (\n above(bounds.minimumDigits) ||\n (bounds.maximumDigits != null && above(bounds.maximumDigits))\n ) {\n fail(\"limit\", \"A quantifier bound is above the reviewed limit.\", location);\n }\n return bounds;\n}\n\nfunction parseQuantifier(state: ParseState): RegExpQuantifier | undefined {\n const start = state.index;\n const character = at(state, 0);\n let bounds:\n | { readonly maximum: number; readonly minimum: number }\n | undefined;\n if (character === \"*\") {\n state.index += 1;\n bounds = { maximum: Number.POSITIVE_INFINITY, minimum: 0 };\n } else if (character === \"+\") {\n state.index += 1;\n bounds = { maximum: Number.POSITIVE_INFINITY, minimum: 1 };\n } else if (character === \"?\") {\n state.index += 1;\n bounds = { maximum: 1, minimum: 0 };\n } else if (character === \"{\") {\n state.index += 1;\n const braced = readBracedQuantifier(state);\n if (braced == null) {\n state.index = start;\n // Annex B reads the brace as an ExtendedPatternCharacter that the\n // next term consumes, so the atom before it stays unquantified.\n if (state.annexB) return undefined;\n refuseAnnexB(\n state,\n \"An unescaped brace is not a pattern character.\",\n \"An unescaped brace\",\n { end: start + 1, start },\n );\n }\n bounds = validateQuantifierBounds(state, braced, start);\n }\n if (bounds == null) return undefined;\n const greedy = !eat(state, \"?\");\n return {\n greedy,\n maximum: bounds.maximum,\n minimum: bounds.minimum,\n span: span(start, state.index),\n };\n}\n\nfunction parseLookaround(state: ParseState): RegExpLookaround | undefined {\n const start = state.index;\n const behind = state.source.startsWith(\"(?<=\", start)\n ? false\n : state.source.startsWith(\"(?<!\", start)\n ? true\n : undefined;\n const ahead = state.source.startsWith(\"(?=\", start)\n ? false\n : state.source.startsWith(\"(?!\", start)\n ? true\n : undefined;\n if (behind == null && ahead == null) return undefined;\n const negated = behind ?? ahead ?? false;\n state.index += behind == null ? 3 : 4;\n const body = parseDisjunction(state);\n expectGroupEnd(state, start);\n return {\n body,\n direction: behind == null ? \"ahead\" : \"behind\",\n kind: \"lookaround\",\n negated,\n span: span(start, state.index),\n };\n}\n\nfunction parseTerm(state: ParseState): RegExpTerm {\n const start = state.index;\n const lookaround = parseLookaround(state);\n if (lookaround != null) {\n if (state.annexB && lookaround.direction === \"ahead\") {\n return quantifyLookahead(state, lookaround);\n }\n return rejectQuantifier(state, lookaround);\n }\n const character = at(state, 0);\n if (character === \"^\" || character === \"$\") {\n state.index += 1;\n return rejectQuantifier(state, {\n assertion: character === \"^\" ? \"start\" : \"end\",\n kind: \"assertion\",\n span: span(start, state.index),\n });\n }\n if (character === \"\\\\\" && (at(state, 1) === \"b\" || at(state, 1) === \"B\")) {\n const negated = at(state, 1) === \"B\";\n state.index += 2;\n return rejectQuantifier(state, {\n assertion: negated ? \"non-word-boundary\" : \"word-boundary\",\n kind: \"assertion\",\n span: span(start, state.index),\n });\n }\n const atom = parseAtom(state);\n const quantifier = parseQuantifier(state);\n if (quantifier == null) return atom;\n return {\n atom,\n kind: \"quantified\",\n quantifier,\n span: span(start, state.index),\n };\n}\n\n/**\n * Read Annex B's QuantifiableAssertion Quantifier.\n *\n * The edition gives a quantified lookahead the semantics of a quantified\n * atom whose matcher is the assertion, which is exactly a non-capturing\n * group around it. The group therefore stands in for the lookahead as the\n * repeated atom, with the lookahead's span, so the matcher and the C\n * backend need no separate repetition form.\n */\nfunction quantifyLookahead(\n state: ParseState,\n lookahead: RegExpLookaround,\n): RegExpTerm {\n const quantifier = parseQuantifier(state);\n if (quantifier == null) return lookahead;\n const location = lookahead.span;\n return {\n atom: {\n body: {\n alternatives: [\n { kind: \"alternative\", span: location, terms: [lookahead] },\n ],\n kind: \"disjunction\",\n span: location,\n },\n kind: \"group\",\n span: location,\n },\n kind: \"quantified\",\n quantifier,\n span: span(location.start, state.index),\n };\n}\n\n/**\n * Reject a quantifier applied to an assertion. The edition admits a\n * quantified assertion only through Annex B, and Annex B quantifies a\n * lookahead alone, which `quantifyLookahead` reads. An edge assertion, a\n * word boundary, and a lookbehind are unquantifiable in every mode, so\n * only a lookahead in a parse without Annex B's grammar reports the\n * `unsupported` kind.\n */\nfunction rejectQuantifier(state: ParseState, term: RegExpTerm): RegExpTerm {\n const character = at(state, 0);\n const quantified =\n character === \"*\" ||\n character === \"+\" ||\n character === \"?\" ||\n (character === \"{\" && bracedQuantifierFollows(state));\n if (quantified) {\n const location = { end: state.index + 1, start: state.index };\n const message = \"An assertion cannot be quantified.\";\n if (term.kind !== \"lookaround\" || term.direction !== \"ahead\") {\n fail(\"invalid\", message, location);\n }\n refuseAnnexB(state, message, \"A quantified lookahead\", location);\n }\n return term;\n}\n\n/**\n * Whether the `{` at the cursor starts a quantifier.\n *\n * A brace that starts no quantifier is its own early error, reported\n * where the next term reads it, so an assertion followed by one is not\n * described as a quantified assertion.\n */\nfunction bracedQuantifierFollows(state: ParseState): boolean {\n const resume = state.index;\n try {\n state.index += 1;\n return readBracedQuantifier(state) != null;\n } finally {\n state.index = resume;\n }\n}\n\nfunction parseAlternative(state: ParseState): RegExpAlternative {\n const start = state.index;\n const terms: RegExpTerm[] = [];\n while (!done(state) && at(state, 0) !== \"|\" && at(state, 0) !== \")\") {\n terms.push(parseTerm(state));\n }\n return { kind: \"alternative\", span: span(start, state.index), terms };\n}\n\nfunction parseDisjunction(state: ParseState): RegExpDisjunction {\n const start = state.index;\n state.depth += 1;\n if (state.depth > state.limits.nestingDepth) {\n fail(\"limit\", \"A pattern nests above the reviewed depth limit.\", {\n end: state.index,\n start,\n });\n }\n const disjunction = state.disjunctionCount;\n state.disjunctionCount += 1;\n const alternatives: RegExpAlternative[] = [];\n for (let index = 0; ; index += 1) {\n state.path.push({ alternative: index, disjunction });\n alternatives.push(parseAlternative(state));\n state.path.pop();\n if (!eat(state, \"|\")) break;\n }\n state.depth -= 1;\n return {\n alternatives,\n kind: \"disjunction\",\n span: span(start, state.index),\n };\n}\n\nfunction parseFlags(text: string): RegExpFlags {\n const seen = new Set<string>();\n const admitted = \"dgimsuvy\";\n for (let index = 0; index < text.length; index += 1) {\n const character = text[index] ?? \"\";\n if (!admitted.includes(character)) {\n fail(\n \"invalid\",\n \"This regular expression flag is not defined.\",\n span(index, index + 1),\n \"flags\",\n );\n }\n if (seen.has(character)) {\n fail(\n \"invalid\",\n \"This regular expression flag is repeated.\",\n span(index, index + 1),\n \"flags\",\n );\n }\n seen.add(character);\n }\n if (seen.has(\"u\") && seen.has(\"v\")) {\n fail(\n \"invalid\",\n \"The u and v flags cannot be combined.\",\n span(0, text.length),\n \"flags\",\n );\n }\n return {\n dotAll: seen.has(\"s\"),\n global: seen.has(\"g\"),\n hasIndices: seen.has(\"d\"),\n ignoreCase: seen.has(\"i\"),\n multiline: seen.has(\"m\"),\n sticky: seen.has(\"y\"),\n text,\n unicode: seen.has(\"u\"),\n unicodeSets: seen.has(\"v\"),\n };\n}\n\n/**\n * Whether two groups with one name can both participate in a match.\n *\n * They cannot when some enclosing disjunction holds them in different\n * alternatives, which is the condition the candidate edition uses to\n * admit a repeated group name.\n */\nfunction mightBothParticipate(\n first: readonly AlternativePath[],\n second: readonly AlternativePath[],\n): boolean {\n const shared = Math.min(first.length, second.length);\n for (let index = 0; index < shared; index += 1) {\n const left = first[index];\n const right = second[index];\n if (left == null || right == null) break;\n if (left.disjunction !== right.disjunction) break;\n if (left.alternative !== right.alternative) return false;\n }\n return true;\n}\n\n/**\n * Order two alternative paths so that adjacent pairs decide the whole\n * set.\n *\n * Exclusivity is transitive along this order: if a sorted neighbor pair\n * diverges at a disjunction, every wider pair diverges at one too, so a\n * sorted scan replaces a comparison of every pair with every other.\n */\nfunction comparePaths(\n first: readonly AlternativePath[],\n second: readonly AlternativePath[],\n): number {\n const shared = Math.min(first.length, second.length);\n for (let index = 0; index < shared; index += 1) {\n const left = first[index];\n const right = second[index];\n if (left == null || right == null) break;\n if (left.disjunction !== right.disjunction) {\n return left.disjunction - right.disjunction;\n }\n if (left.alternative !== right.alternative) {\n return left.alternative - right.alternative;\n }\n }\n return first.length - second.length;\n}\n\nfunction duplicateNameErrors(\n groups: readonly NamedGroupRecord[],\n): readonly RegExpPatternError[] {\n const errors: RegExpPatternError[] = [];\n const byName = new Map<string, NamedGroupRecord[]>();\n for (const group of groups) {\n const existing = byName.get(group.name) ?? [];\n existing.push(group);\n byName.set(group.name, existing);\n }\n for (const named of byName.values()) {\n if (named.length < 2) continue;\n const ordered = named.toSorted((first, second) =>\n comparePaths(first.path, second.path),\n );\n for (let index = 1; index < ordered.length; index += 1) {\n const earlier = ordered[index - 1];\n const later = ordered[index];\n if (earlier == null || later == null) continue;\n if (!mightBothParticipate(earlier.path, later.path)) continue;\n const reported = later.span.start >= earlier.span.start ? later : earlier;\n errors.push({\n kind: \"invalid\",\n message:\n \"This group name repeats one that can participate in the \" +\n \"same match.\",\n section: \"pattern\",\n span: reported.span,\n });\n }\n }\n return errors;\n}\n\nfunction validate(state: ParseState): readonly RegExpPatternError[] {\n const errors: RegExpPatternError[] = [];\n const total = state.captures.length;\n for (const reference of state.backreferences) {\n if (reference.index > total) {\n // Annex B reads a decimal escape past the capture count as a legacy\n // octal or identity escape rather than as a reference.\n errors.push(\n annexBError(\n state,\n \"This backreference names no capturing group.\",\n \"A backreference that names no capturing group\",\n reference.span,\n ),\n );\n }\n }\n errors.push(...duplicateNameErrors(state.namedGroups));\n const indexByName = new Map<string, number[]>();\n for (const capture of state.captures) {\n if (capture.name == null) continue;\n const indices = indexByName.get(capture.name) ?? [];\n indices.push(capture.index);\n indexByName.set(capture.name, indices);\n }\n /*\n * A reference reaches validation only where the grammar's\n * named-reference production was active, so a name it does not declare\n * is an early error a web browser reports too.\n */\n for (const reference of state.namedReferences) {\n if (indexByName.has(reference.name)) continue;\n errors.push({\n kind: \"invalid\",\n message: \"This named backreference names no capturing group.\",\n section: \"pattern\",\n span: reference.span,\n });\n }\n for (const [name, shared] of state.namedReferenceIndices) {\n shared.push(...(indexByName.get(name) ?? []));\n }\n errors.sort((first, second) => first.span.start - second.span.start);\n return errors;\n}\n\n/**\n * Keep one reported span inside the text it addresses.\n *\n * A production that reports the character it expected can name an offset\n * one past the end when the pattern stops early, so the reported span is\n * clamped once here rather than at every such production.\n */\nfunction clampError(\n error: RegExpPatternError,\n input: RegExpPatternInput,\n): RegExpPatternError {\n const length =\n error.section === \"flags\" ? input.flags.length : input.source.length;\n const start = Math.min(Math.max(error.span.start, 0), length);\n const end = Math.min(Math.max(error.span.end, start), length);\n if (start === error.span.start && end === error.span.end) return error;\n return { ...error, span: { end, start } };\n}\n\n/**\n * Parse and validate one pattern and flag text.\n *\n * The result is the owned representation of the pattern; no bootstrap\n * parser node reaches it, and no construct is admitted whose semantics\n * this unit cannot describe.\n */\nexport function parseRegExpPattern(\n input: RegExpPatternInput,\n): RegExpPatternResult {\n const limits = input.limits ?? defaultRegExpPatternLimits;\n try {\n if (input.source.length > limits.sourceLength) {\n fail(\"limit\", \"A pattern is longer than the reviewed limit.\", {\n end: input.source.length,\n start: 0,\n });\n }\n const flags = parseFlags(input.flags);\n const unicodeMode = regExpUnicodeMode(flags);\n const annexB = input.annexB !== false && !unicodeMode;\n const state: ParseState = {\n annexB,\n backreferences: [],\n captureCount: annexB ? countCapturingGroups(input.source) : 0,\n captures: [],\n depth: 0,\n disjunctionCount: 0,\n extensions: input.extensions ?? noExtensions,\n flags,\n groupNameDeclared: scanForGroupName(input.source),\n index: 0,\n limits,\n namedGroups: [],\n namedReferenceIndices: new Map(),\n namedReferences: [],\n path: [],\n source: input.source,\n unicodeMode,\n };\n const body = parseDisjunction(state);\n if (!done(state)) {\n fail(\"invalid\", \"This character must be escaped.\", {\n end: state.index + 1,\n start: state.index,\n });\n }\n const errors = validate(state).map((error) => clampError(error, input));\n if (errors.length > 0) return { errors, parsed: false };\n const groupNames = [\n ...new Set(\n state.captures.flatMap((capture) =>\n capture.name == null ? [] : [capture.name],\n ),\n ),\n ];\n const pattern: RegExpPattern = {\n body,\n captures: state.captures,\n flags,\n groupNames,\n kind: \"pattern\",\n source: input.source,\n };\n return { errors: [], parsed: true, pattern };\n } catch (error) {\n if (error instanceof PatternFailure) {\n return {\n errors: [clampError(error.error, input)],\n parsed: false,\n };\n }\n throw error;\n }\n}\n\n/**\n * Parse one regular expression literal recorded by a frontend.\n *\n * The literal already carries its own source location, so the returned\n * spans stay relative to the pattern and flag text and the frontend maps\n * them back into the source it owns.\n */\nexport function parseRegExpLiteral(\n literal: RegExpLiteralSyntax,\n options: RegExpPatternOptions = {},\n): RegExpPatternResult {\n return parseRegExpPattern({\n flags: literal.flags,\n source: literal.pattern,\n ...options,\n });\n}\n"],"mappings":";;;AAqDA,SAAS,sBACP,YACoD;CACpD,OAAO,WAAW,KAAK,CAAC;AAC1B;;AAGA,MAAM,mCAAmB,IAAI,IAAI,iBAAiB;;AAGlD,MAAM,iCAAiB,IAAI,IAAoB;CAC7C,CAAC,KAAK,EAAI;CACV,CAAC,KAAK,EAAI;CACV,CAAC,KAAK,EAAI;CACV,CAAC,KAAK,CAAI;CACV,CAAC,KAAK,EAAI;AACZ,CAAC;;AAGD,MAAM,gCAAgB,IAAI,IAAY;CAAC;CAAK;CAAK;AAAG,CAAC;;AAGrD,MAAM,0CAA0B,IAAI,IAAY;CAC9C;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAM,2CAA2B,IAAI,IAAY,UAAU;;AAG3D,MAAM,oDAAoC,IAAI,IAC5C,qBACF;AAEA,SAAS,4BAA4B,OAAmB,OAAuB;CAC7E,MAAM,YAAY,GAAG,OAAO,CAAC;CAC7B,IACE,aAAa,SACX,MAAM,eAAe,cAAc,OAClC,MAAM,MAAM,eACX,kCAAkC,IAAI,SAAS,IACnD;EACA,MAAM,SAAS;EACf,OAAO,UAAU,YAAY,CAAC,KAAK;CACrC;CACA,OAAO,oBAAoB,OAAO,OAAO,IAAI;AAC/C;AAEA,MAAM,eAAwC,EAAE,UAAU,CAAC,EAAE;;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"regexp-print.d.ts","names":[],"sources":["../src/regexp-print.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"regexp-print.d.ts","names":[],"sources":["../src/regexp-print.ts"],"mappings":";;;;;;;;;;;iBAwNgB,mBAAmB,SAAS;;;;;;;;;iBAuH5B,mBAAmB,SAAS"}
|
package/dist/regexp-print.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp-print.js","names":[],"sources":["../src/regexp-print.ts"],"sourcesContent":["import type {\n RegExpMatcherInstruction,\n RegExpMatcherProgram,\n RegExpMatcherSet,\n} from \"./regexp-matcher.ts\";\nimport type {\n RegExpAlternative,\n RegExpCharacter,\n RegExpClassItem,\n RegExpClassSetOperand,\n RegExpDisjunction,\n RegExpPattern,\n RegExpQuantifier,\n RegExpTerm,\n RegExpUnicodeClassSet,\n} from \"./regexp.ts\";\n\nfunction quantifierText(quantifier: RegExpQuantifier): string {\n const maximum = Number.isFinite(quantifier.maximum)\n ? String(quantifier.maximum)\n : \"inf\";\n const order = quantifier.greedy ? \"greedy\" : \"lazy\";\n return `${quantifier.minimum}..${maximum} ${order}`;\n}\n\nfunction characterText(value: number): string {\n const text = String.fromCodePoint(value);\n const printable = value > 0x20 && value !== 0x7f && !/\\s/u.test(text);\n const code = value.toString(16).padStart(4, \"0\");\n return printable ? `u+${code} ${text}` : `u+${code}`;\n}\n\nfunction printClassItem(item: RegExpClassItem, indent: string): string {\n if (item.kind === \"character\") {\n return `${indent}char ${characterText(item.value)}\\n`;\n }\n if (item.kind === \"range\") {\n return (\n `${indent}range ${characterText(item.start.value)} .. ` +\n `${characterText(item.end.value)}\\n`\n );\n }\n if (item.kind === \"class-escape\") {\n return `${indent}class-escape ${item.negated ? \"not \" : \"\"}${item.set}\\n`;\n }\n const value = item.value == null ? \"\" : `=${item.value}`;\n return (\n `${indent}property ${item.negated ? \"not \" : \"\"}` +\n `${item.property}${value}\\n`\n );\n}\n\n/**\n * Render one `\\q{...}` alternative.\n *\n * An alternative that spells no character is a member of the class in its\n * own right, so it is named rather than left as a header with no lines\n * under it.\n */\nfunction printClassString(\n characters: readonly RegExpCharacter[],\n indent: string,\n): string {\n if (characters.length === 0) return `${indent}string empty\\n`;\n const nested = `${indent} `;\n return (\n `${indent}string\\n` +\n characters.map((character) => printClassItem(character, nested)).join(\"\")\n );\n}\n\nfunction printClassSetOperand(\n operand: RegExpClassSetOperand,\n indent: string,\n): string {\n if (operand.kind === \"class-set\") return printClassSet(operand, indent);\n if (operand.kind === \"class-strings\") {\n const nested = `${indent} `;\n return (\n `${indent}class-strings\\n` +\n operand.strings\n .map((characters) => printClassString(characters, nested))\n .join(\"\")\n );\n }\n return printClassItem(operand, indent);\n}\n\n/**\n * Render one `v`-mode class set and everything under it.\n *\n * An operand may be another class set or a `\\q{...}` disjunction, so this\n * recurses. Printing only the header would give two structurally different\n * sets the same dump, which is what a structural test compares.\n */\nfunction printClassSet(set: RegExpUnicodeClassSet, indent: string): string {\n const nested = `${indent} `;\n return (\n `${indent}class-set ${set.operation}${set.negated ? \" negated\" : \"\"}\\n` +\n set.operands\n .map((operand) => printClassSetOperand(operand, nested))\n .join(\"\")\n );\n}\n\nfunction printTerm(term: RegExpTerm, indent: string): string {\n const nested = `${indent} `;\n if (term.kind === \"quantified\") {\n return (\n `${indent}repeat ${quantifierText(term.quantifier)}\\n` +\n printTerm(term.atom, nested)\n );\n }\n if (term.kind === \"assertion\") return `${indent}assert ${term.assertion}\\n`;\n if (term.kind === \"lookaround\") {\n const polarity = term.negated ? \"negative\" : \"positive\";\n return (\n `${indent}look ${term.direction} ${polarity}\\n` +\n printDisjunction(term.body, nested)\n );\n }\n if (term.kind === \"character\") {\n return `${indent}char ${characterText(term.value)}\\n`;\n }\n if (term.kind === \"dot\") return `${indent}dot\\n`;\n if (term.kind === \"class-escape\") {\n return `${indent}class-escape ${term.negated ? \"not \" : \"\"}${term.set}\\n`;\n }\n if (term.kind === \"unicode-property\") {\n const value = term.value == null ? \"\" : `=${term.value}`;\n return (\n `${indent}property ${term.negated ? \"not \" : \"\"}` +\n `${term.property}${value}\\n`\n );\n }\n if (term.kind === \"character-class\") {\n return (\n `${indent}class${term.negated ? \" negated\" : \"\"}\\n` +\n term.items.map((item) => printClassItem(item, nested)).join(\"\")\n );\n }\n if (term.kind === \"capturing-group\") {\n const name = term.name == null ? \"\" : ` ${term.name}`;\n return (\n `${indent}capture ${term.index}${name}\\n` +\n printDisjunction(term.body, nested)\n );\n }\n if (term.kind === \"group\") {\n return `${indent}group\\n${printDisjunction(term.body, nested)}`;\n }\n if (term.kind === \"modifier-group\") {\n const enabled = term.enabled.join(\"\");\n const disabled = term.disabled.join(\"\");\n return (\n `${indent}modifiers +${enabled} -${disabled}\\n` +\n printDisjunction(term.body, nested)\n );\n }\n if (term.kind === \"backreference\") {\n return `${indent}backreference ${term.index}\\n`;\n }\n if (term.kind === \"class-set\") return printClassSet(term, indent);\n return `${indent}backreference ${term.name} -> ${term.indices.join(\",\")}\\n`;\n}\n\nfunction printAlternative(\n alternative: RegExpAlternative,\n indent: string,\n): string {\n const nested = `${indent} `;\n return (\n `${indent}alternative\\n` +\n alternative.terms.map((term) => printTerm(term, nested)).join(\"\")\n );\n}\n\nfunction printDisjunction(\n disjunction: RegExpDisjunction,\n indent: string,\n): string {\n const nested = `${indent} `;\n return (\n `${indent}disjunction\\n` +\n disjunction.alternatives\n .map((alternative) => printAlternative(alternative, nested))\n .join(\"\")\n );\n}\n\n/**\n * Render one validated pattern as an indented tree.\n *\n * The dump is the reviewed way to inspect choice order, capture\n * numbering, and reference resolution before any matcher exists. It\n * records the owned model rather than the written text, so two patterns\n * that differ only in how a character was escaped share one dump.\n */\nexport function printRegExpPattern(pattern: RegExpPattern): string {\n const captures = pattern.captures\n .map((capture) =>\n capture.name == null\n ? `${capture.index}`\n : `${capture.index}:${capture.name}`,\n )\n .join(\" \");\n return (\n `pattern /${pattern.source}/${pattern.flags.text}\\n` +\n ` captures ${captures}\\n` +\n printDisjunction(pattern.body, \" \")\n );\n}\n\nfunction address(value: number): string {\n return value.toString().padStart(4, \"0\");\n}\n\nfunction setText(set: RegExpMatcherSet): string {\n const parts: string[] = [];\n for (let index = 0; index + 1 < set.length; index += 2) {\n const start = set[index] ?? 0;\n const end = (set[index + 1] ?? 0) - 1;\n parts.push(\n start === end\n ? `u+${start.toString(16)}`\n : `u+${start.toString(16)}..u+${end.toString(16)}`,\n );\n }\n return parts.length === 0 ? \"empty\" : parts.join(\" \");\n}\n\nfunction instructionText(instruction: RegExpMatcherInstruction): string {\n if (instruction.kind === \"consume\") {\n return (\n `consume ${instruction.backward ? \"backward\" : \"forward\"} ` +\n `set ${instruction.set}`\n );\n }\n if (instruction.kind === \"edge\") {\n return (\n `edge ${instruction.assertion}` +\n `${instruction.multiline ? \" multiline\" : \"\"}`\n );\n }\n if (instruction.kind === \"boundary\") {\n const polarity = instruction.negated ? \"not \" : \"\";\n return `boundary ${polarity}set ${instruction.set}`;\n }\n if (instruction.kind === \"save\") return `save ${instruction.slot}`;\n if (instruction.kind === \"clear\") {\n return `clear ${instruction.from}..${instruction.to}`;\n }\n if (instruction.kind === \"fork\") {\n return (\n `fork ${address(instruction.preferred)} ` +\n address(instruction.alternative)\n );\n }\n if (instruction.kind === \"jump\") return `jump ${address(instruction.target)}`;\n if (instruction.kind === \"repeat\") {\n const maximum = Number.isFinite(instruction.maximum)\n ? String(instruction.maximum)\n : \"inf\";\n return (\n `repeat r${instruction.counter} ${instruction.minimum}..` +\n `${maximum} ${instruction.greedy ? \"greedy\" : \"lazy\"} ` +\n `${address(instruction.enter)} ${address(instruction.exit)}`\n );\n }\n if (instruction.kind === \"repeat-init\") {\n return `repeat-init r${instruction.counter}`;\n }\n if (instruction.kind === \"repeat-enter\") {\n return (\n `repeat-enter r${instruction.counter} r${instruction.position} ` +\n `clear ${instruction.clearFrom}..${instruction.clearTo} ` +\n address(instruction.body)\n );\n }\n if (instruction.kind === \"repeat-end\") {\n return (\n `repeat-end r${instruction.counter} r${instruction.position} ` +\n `min ${instruction.minimum} ${address(instruction.head)}`\n );\n }\n if (instruction.kind === \"look-start\") {\n return (\n `look-start ${instruction.negated ? \"negative\" : \"positive\"} ` +\n `r${instruction.frame} ${address(instruction.body)} ` +\n address(instruction.onFail)\n );\n }\n if (instruction.kind === \"look-end\") {\n return (\n `look-end ${instruction.negated ? \"negative\" : \"positive\"} ` +\n `r${instruction.frame} ${address(instruction.exit)}`\n );\n }\n if (instruction.kind === \"backreference\") {\n return (\n `backreference ${instruction.backward ? \"backward\" : \"forward\"} ` +\n `${instruction.ignoreCase ? \"folded \" : \"\"}` +\n `slots ${instruction.slots.join(\",\")}`\n );\n }\n if (instruction.kind === \"accept\") return \"accept\";\n return \"fail\";\n}\n\n/**\n * Render one matcher artifact as an instruction listing.\n *\n * The dump is the reviewed way to inspect choice order, capture writes,\n * repetition bounds, and lookaround framing before a backend lowers the\n * artifact. It records the compiled program rather than the written\n * pattern, so two patterns that compile to one program share one dump.\n */\nexport function printRegExpMatcher(program: RegExpMatcherProgram): string {\n const captures = program.captures\n .map((capture) =>\n capture.name == null\n ? `${capture.index}`\n : `${capture.index}:${capture.name}`,\n )\n .join(\" \");\n const sets = program.sets.map(\n (set, index) => ` ${index} ${setText(set)}\\n`,\n );\n const code = program.instructions.map(\n (instruction, index) =>\n ` ${address(index)} ${instructionText(instruction)}\\n`,\n );\n return (\n `matcher /${program.source}/${program.flags.text}\\n` +\n ` captures ${captures}\\n` +\n ` registers ${program.registers}\\n` +\n ` sets\\n${sets.join(\"\")}` +\n ` code\\n${code.join(\"\")}`\n );\n}\n"],"mappings":";AAiBA,SAAS,eAAe,YAAsC;CAC5D,MAAM,UAAU,OAAO,SAAS,WAAW,OAAO,IAC9C,OAAO,WAAW,OAAO,IACzB;CACJ,MAAM,QAAQ,WAAW,SAAS,WAAW;CAC7C,OAAO,GAAG,WAAW,QAAQ,IAAI,QAAQ,GAAG;AAC9C;AAEA,SAAS,cAAc,OAAuB;CAC5C,MA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exp-print.js","names":[],"sources":["../src/regexp-print.ts"],"sourcesContent":["/*\n * Oseo, an ahead-of-time compiler for JavaScript and TypeScript.\n * Copyright (C) 2026 Hong Minhee <https://hongminhee.org/>\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <https://www.gnu.org/licenses/>.\n */\n\nimport type {\n RegExpMatcherInstruction,\n RegExpMatcherProgram,\n RegExpMatcherSet,\n} from \"./regexp-matcher.ts\";\nimport type {\n RegExpAlternative,\n RegExpCharacter,\n RegExpClassItem,\n RegExpClassSetOperand,\n RegExpDisjunction,\n RegExpPattern,\n RegExpQuantifier,\n RegExpTerm,\n RegExpUnicodeClassSet,\n} from \"./regexp.ts\";\n\nfunction quantifierText(quantifier: RegExpQuantifier): string {\n const maximum = Number.isFinite(quantifier.maximum)\n ? String(quantifier.maximum)\n : \"inf\";\n const order = quantifier.greedy ? \"greedy\" : \"lazy\";\n return `${quantifier.minimum}..${maximum} ${order}`;\n}\n\nfunction characterText(value: number): string {\n const text = String.fromCodePoint(value);\n const printable = value > 0x20 && value !== 0x7f && !/\\s/u.test(text);\n const code = value.toString(16).padStart(4, \"0\");\n return printable ? `u+${code} ${text}` : `u+${code}`;\n}\n\nfunction printClassItem(item: RegExpClassItem, indent: string): string {\n if (item.kind === \"character\") {\n return `${indent}char ${characterText(item.value)}\\n`;\n }\n if (item.kind === \"range\") {\n return (\n `${indent}range ${characterText(item.start.value)} .. ` +\n `${characterText(item.end.value)}\\n`\n );\n }\n if (item.kind === \"class-escape\") {\n return `${indent}class-escape ${item.negated ? \"not \" : \"\"}${item.set}\\n`;\n }\n const value = item.value == null ? \"\" : `=${item.value}`;\n return (\n `${indent}property ${item.negated ? \"not \" : \"\"}` +\n `${item.property}${value}\\n`\n );\n}\n\n/**\n * Render one `\\q{...}` alternative.\n *\n * An alternative that spells no character is a member of the class in its\n * own right, so it is named rather than left as a header with no lines\n * under it.\n */\nfunction printClassString(\n characters: readonly RegExpCharacter[],\n indent: string,\n): string {\n if (characters.length === 0) return `${indent}string empty\\n`;\n const nested = `${indent} `;\n return (\n `${indent}string\\n` +\n characters.map((character) => printClassItem(character, nested)).join(\"\")\n );\n}\n\nfunction printClassSetOperand(\n operand: RegExpClassSetOperand,\n indent: string,\n): string {\n if (operand.kind === \"class-set\") return printClassSet(operand, indent);\n if (operand.kind === \"class-strings\") {\n const nested = `${indent} `;\n return (\n `${indent}class-strings\\n` +\n operand.strings\n .map((characters) => printClassString(characters, nested))\n .join(\"\")\n );\n }\n return printClassItem(operand, indent);\n}\n\n/**\n * Render one `v`-mode class set and everything under it.\n *\n * An operand may be another class set or a `\\q{...}` disjunction, so this\n * recurses. Printing only the header would give two structurally different\n * sets the same dump, which is what a structural test compares.\n */\nfunction printClassSet(set: RegExpUnicodeClassSet, indent: string): string {\n const nested = `${indent} `;\n return (\n `${indent}class-set ${set.operation}${set.negated ? \" negated\" : \"\"}\\n` +\n set.operands\n .map((operand) => printClassSetOperand(operand, nested))\n .join(\"\")\n );\n}\n\nfunction printTerm(term: RegExpTerm, indent: string): string {\n const nested = `${indent} `;\n if (term.kind === \"quantified\") {\n return (\n `${indent}repeat ${quantifierText(term.quantifier)}\\n` +\n printTerm(term.atom, nested)\n );\n }\n if (term.kind === \"assertion\") return `${indent}assert ${term.assertion}\\n`;\n if (term.kind === \"lookaround\") {\n const polarity = term.negated ? \"negative\" : \"positive\";\n return (\n `${indent}look ${term.direction} ${polarity}\\n` +\n printDisjunction(term.body, nested)\n );\n }\n if (term.kind === \"character\") {\n return `${indent}char ${characterText(term.value)}\\n`;\n }\n if (term.kind === \"dot\") return `${indent}dot\\n`;\n if (term.kind === \"class-escape\") {\n return `${indent}class-escape ${term.negated ? \"not \" : \"\"}${term.set}\\n`;\n }\n if (term.kind === \"unicode-property\") {\n const value = term.value == null ? \"\" : `=${term.value}`;\n return (\n `${indent}property ${term.negated ? \"not \" : \"\"}` +\n `${term.property}${value}\\n`\n );\n }\n if (term.kind === \"character-class\") {\n return (\n `${indent}class${term.negated ? \" negated\" : \"\"}\\n` +\n term.items.map((item) => printClassItem(item, nested)).join(\"\")\n );\n }\n if (term.kind === \"capturing-group\") {\n const name = term.name == null ? \"\" : ` ${term.name}`;\n return (\n `${indent}capture ${term.index}${name}\\n` +\n printDisjunction(term.body, nested)\n );\n }\n if (term.kind === \"group\") {\n return `${indent}group\\n${printDisjunction(term.body, nested)}`;\n }\n if (term.kind === \"modifier-group\") {\n const enabled = term.enabled.join(\"\");\n const disabled = term.disabled.join(\"\");\n return (\n `${indent}modifiers +${enabled} -${disabled}\\n` +\n printDisjunction(term.body, nested)\n );\n }\n if (term.kind === \"backreference\") {\n return `${indent}backreference ${term.index}\\n`;\n }\n if (term.kind === \"class-set\") return printClassSet(term, indent);\n return `${indent}backreference ${term.name} -> ${term.indices.join(\",\")}\\n`;\n}\n\nfunction printAlternative(\n alternative: RegExpAlternative,\n indent: string,\n): string {\n const nested = `${indent} `;\n return (\n `${indent}alternative\\n` +\n alternative.terms.map((term) => printTerm(term, nested)).join(\"\")\n );\n}\n\nfunction printDisjunction(\n disjunction: RegExpDisjunction,\n indent: string,\n): string {\n const nested = `${indent} `;\n return (\n `${indent}disjunction\\n` +\n disjunction.alternatives\n .map((alternative) => printAlternative(alternative, nested))\n .join(\"\")\n );\n}\n\n/**\n * Render one validated pattern as an indented tree.\n *\n * The dump is the reviewed way to inspect choice order, capture\n * numbering, and reference resolution before any matcher exists. It\n * records the owned model rather than the written text, so two patterns\n * that differ only in how a character was escaped share one dump.\n */\nexport function printRegExpPattern(pattern: RegExpPattern): string {\n const captures = pattern.captures\n .map((capture) =>\n capture.name == null\n ? `${capture.index}`\n : `${capture.index}:${capture.name}`,\n )\n .join(\" \");\n return (\n `pattern /${pattern.source}/${pattern.flags.text}\\n` +\n ` captures ${captures}\\n` +\n printDisjunction(pattern.body, \" \")\n );\n}\n\nfunction address(value: number): string {\n return value.toString().padStart(4, \"0\");\n}\n\nfunction setText(set: RegExpMatcherSet): string {\n const parts: string[] = [];\n for (let index = 0; index + 1 < set.length; index += 2) {\n const start = set[index] ?? 0;\n const end = (set[index + 1] ?? 0) - 1;\n parts.push(\n start === end\n ? `u+${start.toString(16)}`\n : `u+${start.toString(16)}..u+${end.toString(16)}`,\n );\n }\n return parts.length === 0 ? \"empty\" : parts.join(\" \");\n}\n\nfunction instructionText(instruction: RegExpMatcherInstruction): string {\n if (instruction.kind === \"consume\") {\n return (\n `consume ${instruction.backward ? \"backward\" : \"forward\"} ` +\n `set ${instruction.set}`\n );\n }\n if (instruction.kind === \"edge\") {\n return (\n `edge ${instruction.assertion}` +\n `${instruction.multiline ? \" multiline\" : \"\"}`\n );\n }\n if (instruction.kind === \"boundary\") {\n const polarity = instruction.negated ? \"not \" : \"\";\n return `boundary ${polarity}set ${instruction.set}`;\n }\n if (instruction.kind === \"save\") return `save ${instruction.slot}`;\n if (instruction.kind === \"clear\") {\n return `clear ${instruction.from}..${instruction.to}`;\n }\n if (instruction.kind === \"fork\") {\n return (\n `fork ${address(instruction.preferred)} ` +\n address(instruction.alternative)\n );\n }\n if (instruction.kind === \"jump\") return `jump ${address(instruction.target)}`;\n if (instruction.kind === \"repeat\") {\n const maximum = Number.isFinite(instruction.maximum)\n ? String(instruction.maximum)\n : \"inf\";\n return (\n `repeat r${instruction.counter} ${instruction.minimum}..` +\n `${maximum} ${instruction.greedy ? \"greedy\" : \"lazy\"} ` +\n `${address(instruction.enter)} ${address(instruction.exit)}`\n );\n }\n if (instruction.kind === \"repeat-init\") {\n return `repeat-init r${instruction.counter}`;\n }\n if (instruction.kind === \"repeat-enter\") {\n return (\n `repeat-enter r${instruction.counter} r${instruction.position} ` +\n `clear ${instruction.clearFrom}..${instruction.clearTo} ` +\n address(instruction.body)\n );\n }\n if (instruction.kind === \"repeat-end\") {\n return (\n `repeat-end r${instruction.counter} r${instruction.position} ` +\n `min ${instruction.minimum} ${address(instruction.head)}`\n );\n }\n if (instruction.kind === \"look-start\") {\n return (\n `look-start ${instruction.negated ? \"negative\" : \"positive\"} ` +\n `r${instruction.frame} ${address(instruction.body)} ` +\n address(instruction.onFail)\n );\n }\n if (instruction.kind === \"look-end\") {\n return (\n `look-end ${instruction.negated ? \"negative\" : \"positive\"} ` +\n `r${instruction.frame} ${address(instruction.exit)}`\n );\n }\n if (instruction.kind === \"backreference\") {\n return (\n `backreference ${instruction.backward ? \"backward\" : \"forward\"} ` +\n `${instruction.ignoreCase ? \"folded \" : \"\"}` +\n `slots ${instruction.slots.join(\",\")}`\n );\n }\n if (instruction.kind === \"accept\") return \"accept\";\n return \"fail\";\n}\n\n/**\n * Render one matcher artifact as an instruction listing.\n *\n * The dump is the reviewed way to inspect choice order, capture writes,\n * repetition bounds, and lookaround framing before a backend lowers the\n * artifact. It records the compiled program rather than the written\n * pattern, so two patterns that compile to one program share one dump.\n */\nexport function printRegExpMatcher(program: RegExpMatcherProgram): string {\n const captures = program.captures\n .map((capture) =>\n capture.name == null\n ? `${capture.index}`\n : `${capture.index}:${capture.name}`,\n )\n .join(\" \");\n const sets = program.sets.map(\n (set, index) => ` ${index} ${setText(set)}\\n`,\n );\n const code = program.instructions.map(\n (instruction, index) =>\n ` ${address(index)} ${instructionText(instruction)}\\n`,\n );\n return (\n `matcher /${program.source}/${program.flags.text}\\n` +\n ` captures ${captures}\\n` +\n ` registers ${program.registers}\\n` +\n ` sets\\n${sets.join(\"\")}` +\n ` code\\n${code.join(\"\")}`\n );\n}\n"],"mappings":";AAmCA,SAAS,eAAe,YAAsC;CAC5D,MAAM,UAAU,OAAO,SAAS,WAAW,OAAO,IAC9C,OAAO,WAAW,OAAO,IACzB;CACJ,MAAM,QAAQ,WAAW,SAAS,WAA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QAAQ,UAAU,YACtB,KAAK,KAAK,EAAE,YACZ,KAAK,KAAK,EAAE;AAE3B"}
|
package/dist/regexp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regexp.d.ts","names":[],"sources":["../src/regexp.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"regexp.d.ts","names":[],"sources":["../src/regexp.ts"],"mappings":";;;;;;;;;UA0BiB;WACN;WACA;;;KAIC;;;;;;;;UASK;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;iBAIK,kBAAkB,OAAO;;KAK7B;;UAOK;WACN,WAAW;WACX;WACA,MAAM;;;KAIL;;UAGK;WACN,MAAM;WACN,WAAW;WACX;WACA;WACA,MAAM;;;;;;;;;UAUA;WACN;WACA;WACA;WACA,MAAM;;;UAIA;WACN,MAAM;WACN;WACA,YAAY;WACZ,MAAM;;;UAIA;WACN;WACA,MAAM;WACN;;;UAIM;WACN;WACA,MAAM;;;KAIL;;UAGK;WACN;WACA;WACA,KAAK;WACL,MAAM;;;;;;;;;;UAWA;WACN;WACA;WACA;WACA,MAAM;WACN;;;UAIM;WACN,KAAK;WACL;WACA,MAAM;WACN,OAAO;;;KAIN,kBACR,kBACA,uBACA,oBACA;;UAGa;WACN,gBAAgB;WAChB;WACA;WACA,MAAM;;;UAIA;WACN;WACA,MAAM;WACN,4BAA4B;;;KAI3B,wBACR,kBACA,uBACA,oBACA,+BACA,wBACA;;KAGQ;;UAGK;WACN;WACA;WACA,mBAAmB;WACnB,WAAW;WACX,MAAM;;;UAIA;WACN,MAAM;WACN;WACA;WACA;WACA,MAAM;;;UAIA;WACN,MAAM;WACN;WACA,MAAM;;;KAIL;;;;;;;;UASK;WACN,MAAM;WACN,mBAAmB;WACnB,kBAAkB;WAClB;WACA,MAAM;;;UAIA;WACN;WACA;WACA,MAAM;;;;;;;;;UAUA;WACN;WACA;WACA;WACA,MAAM;;;KAIL,aACR,sBACA,uBACA,kBACA,uBACA,wBACA,oBACA,YACA,cACA,sBACA,2BACA;;KAGQ,aACR,aACA,sBACA,mBACA;;UAGa;WACN;WACA,MAAM;WACN,gBAAgB;;;UAIV;WACN,uBAAuB;WACvB;WACA,MAAM;;;UAIA;WACN;WACA;WACA,MAAM;;;;;;;;UASA;WACN,MAAM;WACN,mBAAmB;WACnB,OAAO;WACP;WACA;WACA;;;KAIC;;KAGA;;;;;;;;;;UAWK;WACN,MAAM;WACN;WACA,SAAS;WACT,MAAM;;;;;;;;;KAUL;;;;;;;;;;;;UAgBK;WACN,mBAAmB;WACnB,kBAAkB;WAClB,mBAAmB;WACnB,mBAAmB,QAAQ;;;;;;;;;UAUrB;WACN;WACA;WACA;WACA;;;;;;;;;cAUE,4BAA4B;;UAQxB;;;;;;;;WAQN;WACA,aAAa;WACb,SAAS;;;UAIH,2BAA2B;WACjC;WACA;;;;;;;;UASM;WACN,iBAAiB;WACjB;WACA,UAAU"}
|