@wolfstar/rust-regex 0.0.0-stage → 0.1.2
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/LICENSE +201 -0
- package/README.md +96 -2
- package/dist/esm/index.d.ts +82 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +1233 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +60 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/lib/errors.ts","../../src/lib/emitter.ts","../../src/lib/properties.ts","../../src/lib/parser.ts","../../src/lib/transpile.ts"],"sourcesContent":["/**\n * The reason a pattern could not be transpiled.\n *\n * - `invalid_syntax`: the Rust `regex` crate would reject the pattern as well.\n * - `unsupported_lookaround`: lookahead and lookbehind do not exist in Rust, so Discord rejects them.\n * - `unsupported_backreference`: backreferences do not exist in Rust, so Discord rejects them.\n * - `unsupported_feature`: valid Rust syntax that this package cannot express with a JavaScript `RegExp`.\n * - `invalid_output`: the pattern was parsed, but the JavaScript engine refuses the result, for example an\n * unknown Unicode script name, or scoped flags (`(?i:...)`) on a runtime older than ES2025.\n * - `invalid_option`: an option the caller passed is wrong, for example an unknown Rust flag or an unsupported\n * JavaScript flag in `extraFlags`. The pattern itself is not at fault.\n */\nexport type RustRegexErrorCode =\n\t| 'invalid_syntax'\n\t| 'unsupported_lookaround'\n\t| 'unsupported_backreference'\n\t| 'unsupported_feature'\n\t| 'invalid_output'\n\t| 'invalid_option';\n\n/**\n * Thrown when a Rust regular expression cannot be transpiled.\n */\nexport class RustRegexError extends SyntaxError {\n\t/** What went wrong, so callers can tell a Rust mistake from a limitation of this package. */\n\tpublic readonly code: RustRegexErrorCode;\n\n\t/** The Rust pattern that was being transpiled. */\n\tpublic readonly pattern: string;\n\n\t/**\n\t * The UTF-16 index in {@link RustRegexError.pattern} where the problem was found, or `undefined` when the problem\n\t * is not at a place in the pattern: a wrong option, or a result the JavaScript engine refuses.\n\t */\n\tpublic readonly position: number | undefined;\n\n\tpublic constructor(code: RustRegexErrorCode, message: string, pattern: string, position?: number) {\n\t\tsuper(position === undefined ? `${message} (in /${pattern}/)` : `${message} (at index ${position} of /${pattern}/)`);\n\t\tthis.name = 'RustRegexError';\n\t\tthis.code = code;\n\t\tthis.pattern = pattern;\n\t\tthis.position = position;\n\t}\n}\n","import type { AssertionKind, ClassExpr, ClassItem, ClassSet, Node, PerlClass } from './ast.js';\nimport { RustRegexError } from './errors.js';\n\n/**\n * Unicode `\\w` as Rust defines it (UTS #18): letters, marks, decimal digits, connector punctuation and joiners.\n * JavaScript's own `\\w` is ASCII only, so it cannot be used, even with the `u` or `v` flag.\n */\nconst WORD_CONTENT = String.raw`\\p{Alphabetic}\\p{M}\\p{Nd}\\p{Pc}\\p{Join_Control}`;\nconst WORD = `[${WORD_CONTENT}]`;\n\nconst ASSERTIONS: Readonly<Record<AssertionKind, string>> = {\n\t'text-start': '^',\n\t'text-end': '$',\n\t// Start or end of the text, or next to a `\\n`. JavaScript's `m` flag would also look at `\\r` and at the Unicode line and paragraph separators.\n\t'line-start': String.raw`(?<![^\\n])`,\n\t'line-end': String.raw`(?![^\\n])`,\n\t// Unicode word boundaries, which JavaScript's `\\b` is not.\n\t'word-boundary': `(?:(?<=${WORD})(?!${WORD})|(?<!${WORD})(?=${WORD}))`,\n\t'not-word-boundary': `(?:(?<=${WORD})(?=${WORD})|(?<!${WORD})(?!${WORD}))`\n};\n\n/** Characters that are syntax outside of a class. */\nconst SYNTAX_CHARACTERS = new Set('^$\\\\.*+?()[]{}|/');\n\n/**\n * Characters that need a backslash inside a class under the `v` flag: the class syntax characters and the reserved\n * punctuators, which also covers the doubled ones (`&&`, `!!`, `##`, ...) the flag refuses to see unescaped.\n */\nconst CLASS_ESCAPES = new Set('()[]{}/-\\\\|&!#%,:;<=>@`~$*+.?^');\n\n/**\n * The longest source, in UTF-16 units, that one `~~` may produce. Each `~~` writes both of its sides twice, so a short\n * chain such as `[a~~b~~b~~b...]` doubles its output at every step and would otherwise run out of memory.\n */\nconst MAX_SYMMETRIC_DIFFERENCE_LENGTH = 1_000_000;\n\n/** Thrown by the class writers, which know no pattern, and turned into a {@link RustRegexError} by {@link Emitter.emit}. */\nconst OUTPUT_TOO_LARGE = Symbol('output too large');\n\nfunction isPrintableAscii(cp: number): boolean {\n\treturn cp >= 0x20 && cp <= 0x7e;\n}\n\nfunction hex(cp: number): string {\n\treturn String.raw`\\u{${cp.toString(16)}}`;\n}\n\nfunction literal(cp: number): string {\n\tif (!isPrintableAscii(cp)) return hex(cp);\n\n\tconst ch = String.fromCharCode(cp);\n\treturn SYNTAX_CHARACTERS.has(ch) ? `\\\\${ch}` : ch;\n}\n\nfunction classChar(cp: number): string {\n\tif (!isPrintableAscii(cp)) return hex(cp);\n\n\tconst ch = String.fromCharCode(cp);\n\treturn CLASS_ESCAPES.has(ch) ? `\\\\${ch}` : ch;\n}\n\nfunction property(expr: string, negated: boolean): string {\n\treturn `\\\\${negated ? 'P' : 'p'}{${expr}}`;\n}\n\nfunction perl(cls: PerlClass, negated: boolean): string {\n\tswitch (cls) {\n\t\tcase 'd':\n\t\t\treturn property('Nd', negated);\n\t\tcase 's':\n\t\t\treturn property('White_Space', negated);\n\t\tcase 'w':\n\t\t\treturn `[${negated ? '^' : ''}${WORD_CONTENT}]`;\n\t}\n}\n\n/** What a perl class or property adds to a bracketed class, which is not always a bracket of its own. */\nfunction perlInClass(cls: PerlClass, negated: boolean): string {\n\treturn cls === 'w' && !negated ? WORD_CONTENT : perl(cls, negated);\n}\n\nfunction item(entry: ClassItem): string {\n\tswitch (entry.kind) {\n\t\tcase 'char':\n\t\t\treturn classChar(entry.cp);\n\t\tcase 'range':\n\t\t\treturn `${classChar(entry.lo)}-${classChar(entry.hi)}`;\n\t\tcase 'perl':\n\t\t\treturn perlInClass(entry.cls, entry.negated);\n\t\tcase 'property':\n\t\t\treturn property(entry.expr, entry.negated);\n\t\tcase 'class':\n\t\t\treturn bracket(entry.set);\n\t}\n}\n\n/**\n * Under the `v` flag the operands of `&&` and `--` cannot be ranges or runs of characters, only a single character or\n * a nested class, so each side is always wrapped in a class of its own.\n */\nfunction operand(expr: ClassExpr): string {\n\treturn `[${body(expr)}]`;\n}\n\nfunction body(expr: ClassExpr): string {\n\tif (expr.kind === 'union') return expr.items.map(item).join('');\n\n\tif (expr.op === '~~') {\n\t\t// `a ~~ b` is `(a -- b) || (b -- a)`.\n\t\tconst left = operand(expr.left);\n\t\tconst right = operand(expr.right);\n\t\tif (left.length + right.length > MAX_SYMMETRIC_DIFFERENCE_LENGTH / 2) throw OUTPUT_TOO_LARGE;\n\n\t\treturn `[${left}--${right}][${right}--${left}]`;\n\t}\n\n\treturn `${operand(expr.left)}${expr.op}${operand(expr.right)}`;\n}\n\nfunction bracket(set: ClassSet): string {\n\treturn `[${set.negated ? '^' : ''}${body(set.expr)}]`;\n}\n\nfunction classNode(set: ClassSet): string {\n\tconst { expr } = set;\n\tif (!set.negated && expr.kind === 'union' && expr.items.length === 1) {\n\t\tconst only = expr.items[0];\n\t\tif (only?.kind === 'perl') return perl(only.cls, only.negated);\n\t\tif (only?.kind === 'property') return property(only.expr, only.negated);\n\t}\n\n\treturn bracket(set);\n}\n\n/** Case-insensitive state while walking a sequence. A `(?i)` changes it for the rest of the enclosing group. */\ninterface State {\n\trustI: boolean;\n}\n\nexport interface EmitResult {\n\treadonly source: string;\n\treadonly usesModifiers: boolean;\n}\n\n/**\n * Turns the parsed pattern into the source of a JavaScript `RegExp` that is meant to run with the `v` flag, and with\n * the `i` flag when `initialI` is set.\n *\n * Only case-insensitivity has to be a flag: everything else (`s`, `m`, `U`, `x`) was settled while parsing and is\n * written out explicitly, so the one thing that can change inside the pattern is `i`. That is expressed with the\n * ES2025 modifiers `(?i:...)` and `(?-i:...)`, and only when the pattern actually switches it.\n */\nexport class Emitter {\n\tprivate usesModifiers = false;\n\n\tpublic constructor(private readonly pattern: string) {}\n\n\tpublic emit(alt: Node[][], initialI: boolean): EmitResult {\n\t\ttry {\n\t\t\tconst source = this.alt(alt, { rustI: initialI }, initialI);\n\t\t\treturn { source: source === '' ? '(?:)' : source, usesModifiers: this.usesModifiers };\n\t\t} catch (error) {\n\t\t\tif (error !== OUTPUT_TOO_LARGE) throw error;\n\n\t\t\tthrow new RustRegexError(\n\t\t\t\t'unsupported_feature',\n\t\t\t\t'the symmetric difference \"~~\" nests too deeply to be written as a JavaScript RegExp',\n\t\t\t\tthis.pattern\n\t\t\t);\n\t\t}\n\t}\n\n\t/** `jsI` is whether the JavaScript engine is matching case-insensitively at this point of the output. */\n\tprivate alt(branches: Node[][], state: State, jsI: boolean): string {\n\t\treturn branches.map((branch) => this.seq(branch, state, jsI)).join('|');\n\t}\n\n\tprivate seq(nodes: Node[], state: State, jsI: boolean): string {\n\t\tlet out = '';\n\t\tlet closers = 0;\n\t\tlet current = jsI;\n\n\t\tfor (const node of nodes) {\n\t\t\tif (node.type === 'flags') {\n\t\t\t\tstate.rustI = node.i;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Opens a modifier group when Rust's state and the engine's disagree, and only once something follows that\n\t\t\t// it applies to. It stays open to the end of the branch.\n\t\t\tif (state.rustI !== current) {\n\t\t\t\tout += state.rustI ? '(?i:' : '(?-i:';\n\t\t\t\tclosers++;\n\t\t\t\tcurrent = state.rustI;\n\t\t\t\tthis.usesModifiers = true;\n\t\t\t}\n\n\t\t\tout += this.node(node, current);\n\t\t}\n\n\t\treturn out + ')'.repeat(closers);\n\t}\n\n\tprivate node(node: Node, jsI: boolean): string {\n\t\tswitch (node.type) {\n\t\t\tcase 'literal':\n\t\t\t\treturn literal(node.cp);\n\t\t\tcase 'dot':\n\t\t\t\treturn node.dotAll ? String.raw`[\\s\\S]` : String.raw`[^\\n]`;\n\t\t\tcase 'assertion':\n\t\t\t\treturn ASSERTIONS[node.kind];\n\t\t\tcase 'class':\n\t\t\t\treturn classNode(node.set);\n\t\t\tcase 'group':\n\t\t\t\treturn this.group(node, jsI);\n\t\t\tcase 'repeat':\n\t\t\t\treturn this.repeat(node, jsI);\n\t\t\tcase 'flags':\n\t\t\t\treturn '';\n\t\t}\n\t}\n\n\tprivate group(node: Extract<Node, { type: 'group' }>, jsI: boolean): string {\n\t\tconst inner: State = { rustI: node.iStart };\n\n\t\tif (node.capture) {\n\t\t\tconst open = node.name === undefined ? '(' : `(?<${node.name}>`;\n\t\t\treturn `${open}${this.alt(node.alt, inner, jsI)})`;\n\t\t}\n\n\t\t// `(?i:...)` in the Rust pattern is the same modifier group here, so it does not need a second one inside.\n\t\tif (node.iStart !== jsI) {\n\t\t\tthis.usesModifiers = true;\n\t\t\treturn `${node.iStart ? '(?i:' : '(?-i:'}${this.alt(node.alt, inner, node.iStart)})`;\n\t\t}\n\n\t\treturn `(?:${this.alt(node.alt, inner, jsI)})`;\n\t}\n\n\tprivate repeat(node: Extract<Node, { type: 'repeat' }>, jsI: boolean): string {\n\t\tconst { min, max } = node;\n\t\tconst quantifier =\n\t\t\tmin === 0 && max === null\n\t\t\t\t? '*'\n\t\t\t\t: min === 1 && max === null\n\t\t\t\t\t? '+'\n\t\t\t\t\t: min === 0 && max === 1\n\t\t\t\t\t\t? '?'\n\t\t\t\t\t\t: max === null\n\t\t\t\t\t\t\t? `{${min},}`\n\t\t\t\t\t\t\t: min === max\n\t\t\t\t\t\t\t\t? `{${min}}`\n\t\t\t\t\t\t\t\t: `{${min},${max}}`;\n\n\t\t// Assertions and other quantifiers cannot be quantified directly under the `v` flag.\n\t\tconst child = this.node(node.node, jsI);\n\t\tconst wrapped = node.node.type === 'assertion' || node.node.type === 'repeat' ? `(?:${child})` : child;\n\n\t\treturn `${wrapped}${quantifier}${node.lazy ? '?' : ''}`;\n\t}\n}\n","/**\n * Rust's `\\p{...}` accepts names the way UTS #18 loose matching does (case, spaces, `_` and `-` are ignored) and lets\n * a bare name stand for a binary property, a general category or a script. JavaScript is strict about spelling and\n * needs `Script=` for scripts, so every name is resolved here to the form JavaScript understands.\n */\n\nexport type PropertyResolution =\n\t| { readonly expr: string; readonly negated: boolean }\n\t| { readonly error: 'invalid' | 'unsupported'; readonly message: string };\n\nfunction normalize(name: string): string {\n\treturn name.toLowerCase().replace(/[\\s_-]/g, '');\n}\n\nfunction buildMap(entries: ReadonlyArray<readonly string[]>): ReadonlyMap<string, string> {\n\tconst map = new Map<string, string>();\n\tfor (const [canonical, ...aliases] of entries) {\n\t\tif (canonical === undefined) continue;\n\t\tmap.set(normalize(canonical), canonical);\n\t\tfor (const alias of aliases) map.set(normalize(alias), canonical);\n\t}\n\n\treturn map;\n}\n\n/** The first entry is what is emitted, the rest are spellings Rust accepts. */\nconst GENERAL_CATEGORIES = buildMap([\n\t['L', 'Letter'],\n\t['Lu', 'Uppercase_Letter'],\n\t['Ll', 'Lowercase_Letter'],\n\t['Lt', 'Titlecase_Letter'],\n\t['LC', 'Cased_Letter'],\n\t['Lm', 'Modifier_Letter'],\n\t['Lo', 'Other_Letter'],\n\t['M', 'Mark', 'Combining_Mark'],\n\t['Mn', 'Nonspacing_Mark'],\n\t['Mc', 'Spacing_Mark'],\n\t['Me', 'Enclosing_Mark'],\n\t['N', 'Number'],\n\t['Nd', 'Decimal_Number', 'digit'],\n\t['Nl', 'Letter_Number'],\n\t['No', 'Other_Number'],\n\t['P', 'Punctuation', 'punct'],\n\t['Pc', 'Connector_Punctuation'],\n\t['Pd', 'Dash_Punctuation'],\n\t['Ps', 'Open_Punctuation'],\n\t['Pe', 'Close_Punctuation'],\n\t['Pi', 'Initial_Punctuation'],\n\t['Pf', 'Final_Punctuation'],\n\t['Po', 'Other_Punctuation'],\n\t['S', 'Symbol'],\n\t['Sm', 'Math_Symbol'],\n\t['Sc', 'Currency_Symbol'],\n\t['Sk', 'Modifier_Symbol'],\n\t['So', 'Other_Symbol'],\n\t['Z', 'Separator'],\n\t['Zs', 'Space_Separator'],\n\t['Zl', 'Line_Separator'],\n\t['Zp', 'Paragraph_Separator'],\n\t['C', 'Other'],\n\t['Cc', 'Control', 'cntrl'],\n\t['Cf', 'Format'],\n\t['Cs', 'Surrogate'],\n\t['Co', 'Private_Use'],\n\t['Cn', 'Unassigned']\n]);\n\nconst BINARY_PROPERTIES = buildMap([\n\t['ASCII'],\n\t['ASCII_Hex_Digit', 'AHex'],\n\t['Alphabetic', 'Alpha'],\n\t['Any'],\n\t['Assigned'],\n\t['Bidi_Control', 'Bidi_C'],\n\t['Bidi_Mirrored', 'Bidi_M'],\n\t['Case_Ignorable', 'CI'],\n\t['Cased'],\n\t['Changes_When_Casefolded', 'CWCF'],\n\t['Changes_When_Casemapped', 'CWCM'],\n\t['Changes_When_Lowercased', 'CWL'],\n\t['Changes_When_NFKC_Casefolded', 'CWKCF'],\n\t['Changes_When_Titlecased', 'CWT'],\n\t['Changes_When_Uppercased', 'CWU'],\n\t['Dash'],\n\t['Default_Ignorable_Code_Point', 'DI'],\n\t['Deprecated', 'Dep'],\n\t['Diacritic', 'Dia'],\n\t['Emoji'],\n\t['Emoji_Component', 'EComp'],\n\t['Emoji_Modifier', 'EMod'],\n\t['Emoji_Modifier_Base', 'EBase'],\n\t['Emoji_Presentation', 'EPres'],\n\t['Extended_Pictographic', 'ExtPict'],\n\t['Extender', 'Ext'],\n\t['Grapheme_Base', 'Gr_Base'],\n\t['Grapheme_Extend', 'Gr_Ext'],\n\t['Hex_Digit', 'Hex'],\n\t['IDS_Binary_Operator', 'IDSB'],\n\t['IDS_Trinary_Operator', 'IDST'],\n\t['ID_Continue', 'IDC'],\n\t['ID_Start', 'IDS'],\n\t['Ideographic', 'Ideo'],\n\t['Join_Control', 'Join_C'],\n\t['Logical_Order_Exception', 'LOE'],\n\t['Lowercase', 'Lower'],\n\t['Math'],\n\t['Noncharacter_Code_Point', 'NChar'],\n\t['Pattern_Syntax', 'Pat_Syn'],\n\t['Pattern_White_Space', 'Pat_WS'],\n\t['Quotation_Mark', 'QMark'],\n\t['Radical'],\n\t['Regional_Indicator', 'RI'],\n\t['Sentence_Terminal', 'STerm'],\n\t['Soft_Dotted', 'SD'],\n\t['Terminal_Punctuation', 'Term'],\n\t['Unified_Ideograph', 'UIdeo'],\n\t['Uppercase', 'Upper'],\n\t['Variation_Selector', 'VS'],\n\t['White_Space', 'space'],\n\t['XID_Continue', 'XIDC'],\n\t['XID_Start', 'XIDS']\n]);\n\n/**\n * JavaScript wants `Old_Italic`, Rust also takes `olditalic`. Without the full script table the best that can be done\n * is to title-case every word, which is right for every script name except the ones listed here. A name that is still\n * wrong is rejected by the JavaScript engine, which `transpile` reports as an `invalid_output` error.\n */\nconst SCRIPT_EXCEPTIONS: ReadonlyMap<string, string> = new Map([['signwriting', 'SignWriting']]);\n\nfunction scriptName(value: string): string {\n\tconst exception = SCRIPT_EXCEPTIONS.get(normalize(value));\n\tif (exception !== undefined) return exception;\n\n\treturn value\n\t\t.trim()\n\t\t.split(/[\\s_-]+/)\n\t\t.map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())\n\t\t.join('_');\n}\n\nconst SINGLE_LETTER_CATEGORIES = new Set(['L', 'M', 'N', 'P', 'S', 'Z', 'C']);\n\nconst KEY_VALUE = /^\\s*([A-Za-z_ -]+?)\\s*(!=|=|:)\\s*(.+?)\\s*$/;\n\n/**\n * @param spec What is between the braces of `\\p{...}`, without a leading `^`, or the letter of `\\pL`.\n * @param singleLetter Whether `spec` came from the `\\pL` form, which only accepts the one-letter categories.\n */\nexport function resolveProperty(spec: string, singleLetter: boolean): PropertyResolution {\n\tif (singleLetter) {\n\t\treturn SINGLE_LETTER_CATEGORIES.has(spec)\n\t\t\t? { expr: spec, negated: false }\n\t\t\t: { error: 'invalid', message: `unknown Unicode class \\\\p${spec}` };\n\t}\n\n\tconst keyValue = KEY_VALUE.exec(spec);\n\tif (keyValue !== null) {\n\t\tconst [, key = '', operator = '=', value = ''] = keyValue;\n\t\tconst negated = operator === '!=';\n\n\t\tswitch (normalize(key)) {\n\t\t\tcase 'gc':\n\t\t\tcase 'generalcategory':\n\t\t\tcase 'category': {\n\t\t\t\tconst category = GENERAL_CATEGORIES.get(normalize(value));\n\t\t\t\treturn category === undefined ? { error: 'invalid', message: `unknown general category \"${value}\"` } : { expr: category, negated };\n\t\t\t}\n\t\t\tcase 'sc':\n\t\t\tcase 'script':\n\t\t\t\treturn { expr: `Script=${scriptName(value)}`, negated };\n\t\t\tcase 'scx':\n\t\t\tcase 'scriptextensions':\n\t\t\t\treturn { expr: `Script_Extensions=${scriptName(value)}`, negated };\n\t\t\tdefault:\n\t\t\t\treturn { error: 'unsupported', message: `the Unicode property \"${key}\" cannot be expressed in JavaScript` };\n\t\t}\n\t}\n\n\tconst name = normalize(spec);\n\tconst binary = BINARY_PROPERTIES.get(name);\n\tif (binary !== undefined) return { expr: binary, negated: false };\n\n\tconst category = GENERAL_CATEGORIES.get(name);\n\tif (category !== undefined) return { expr: category, negated: false };\n\n\tif (!/^[A-Za-z][A-Za-z _-]*$/.test(spec)) return { error: 'invalid', message: `unknown Unicode class \"${spec}\"` };\n\n\treturn { expr: `Script=${scriptName(spec)}`, negated: false };\n}\n","import type { AssertionKind, ClassExpr, ClassItem, ClassOp, ClassSet, Node, PerlClass } from './ast.js';\nimport { RustRegexError, type RustRegexErrorCode } from './errors.js';\nimport { resolveProperty } from './properties.js';\n\n/** The flags that change how a pattern is read or matched. `u` and `R` are handled where they are parsed. */\nexport interface Flags {\n\ti: boolean;\n\tm: boolean;\n\ts: boolean;\n\tU: boolean;\n\tx: boolean;\n}\n\nexport interface ParseResult {\n\treadonly alt: Node[][];\n\t/** Case-insensitive state at the very start of the pattern, after any leading `(?i)`. */\n\treadonly initialI: boolean;\n}\n\n/** The nesting limit of the Rust `regex` crate. */\nconst NEST_LIMIT = 250;\n\nconst MAX_CODE_POINT = 0x10ffff;\n\nconst ASCII_CLASSES: Readonly<Record<string, readonly (readonly [number, number])[]>> = {\n\talnum: [\n\t\t[0x30, 0x39],\n\t\t[0x41, 0x5a],\n\t\t[0x61, 0x7a]\n\t],\n\talpha: [\n\t\t[0x41, 0x5a],\n\t\t[0x61, 0x7a]\n\t],\n\tascii: [[0x00, 0x7f]],\n\tblank: [\n\t\t[0x20, 0x20],\n\t\t[0x09, 0x09]\n\t],\n\tcntrl: [\n\t\t[0x00, 0x1f],\n\t\t[0x7f, 0x7f]\n\t],\n\tdigit: [[0x30, 0x39]],\n\tgraph: [[0x21, 0x7e]],\n\tlower: [[0x61, 0x7a]],\n\tprint: [[0x20, 0x7e]],\n\tpunct: [\n\t\t[0x21, 0x2f],\n\t\t[0x3a, 0x40],\n\t\t[0x5b, 0x60],\n\t\t[0x7b, 0x7e]\n\t],\n\tspace: [\n\t\t[0x09, 0x0d],\n\t\t[0x20, 0x20]\n\t],\n\tupper: [[0x41, 0x5a]],\n\tword: [\n\t\t[0x30, 0x39],\n\t\t[0x41, 0x5a],\n\t\t[0x5f, 0x5f],\n\t\t[0x61, 0x7a]\n\t],\n\txdigit: [\n\t\t[0x30, 0x39],\n\t\t[0x41, 0x46],\n\t\t[0x61, 0x66]\n\t]\n};\n\nconst ASCII_CLASS = /\\[:(\\^?)([a-z]+):\\]/y;\n\nconst WHITESPACE = /^\\p{White_Space}$/u;\n\n/** What the Rust `regex` crate accepts as a capture group name: a letter or `_`, then letters, numbers, `_`, `.`, `[` and `]`. */\nconst RUST_GROUP_NAME = /^[_\\p{Alphabetic}][_.[\\]\\p{Alphabetic}\\p{N}]*$/u;\n\n/** What JavaScript accepts as a capture group name: an identifier. */\nconst JS_GROUP_NAME = /^[_\\p{ID_Start}]\\p{ID_Continue}*$/u;\n\n/** What the parser hands back for an atom: the node, and whether a quantifier may follow it. */\ninterface Parsed {\n\treadonly node: Node;\n\treadonly repeatable: boolean;\n}\n\ntype Escape =\n\t| { readonly kind: 'char'; readonly cp: number }\n\t| { readonly kind: 'item'; readonly item: ClassItem }\n\t| { readonly kind: 'assertion'; readonly assertion: AssertionKind };\n\nfunction isAsciiAlphanumeric(ch: string): boolean {\n\treturn (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');\n}\n\nfunction union(items: readonly ClassItem[]): ClassExpr {\n\treturn { kind: 'union', items };\n}\n\nclass Parser {\n\tprivate pos = 0;\n\tprivate depth = 0;\n\tprivate readonly names = new Set<string>();\n\n\t/**\n\t * How many levels of groups, repetitions and classes sit below a node, counted the way the nest limit of the Rust\n\t * `regex` crate counts the depth of its tree. A chain such as `a*****...` adds a level per operator without opening\n\t * a group, so `depth` alone would not stop it, and the emitter would overflow the stack on it.\n\t */\n\tprivate readonly heights = new WeakMap<object, number>();\n\n\tpublic constructor(private readonly src: string) {}\n\n\tpublic parse(flags: Flags): Node[][] {\n\t\tconst alt = this.parseAlternation(flags);\n\t\tif (this.pos < this.src.length) throw this.error('invalid_syntax', 'unopened group: found an unmatched \")\"');\n\n\t\treturn alt;\n\t}\n\n\tprivate error(code: RustRegexErrorCode, message: string, position = this.pos): RustRegexError {\n\t\treturn new RustRegexError(code, message, this.src, position);\n\t}\n\n\tprivate enter(): void {\n\t\tif (++this.depth > NEST_LIMIT) throw this.nestLimit();\n\t}\n\n\tprivate nestLimit(position = this.pos): RustRegexError {\n\t\treturn this.error('invalid_syntax', `exceeded the nest limit of ${NEST_LIMIT}`, position);\n\t}\n\n\tprivate height(value: object): number {\n\t\treturn this.heights.get(value) ?? 0;\n\t}\n\n\tprivate withHeight<T extends object>(value: T, height: number, start: number): T {\n\t\tif (height > NEST_LIMIT) throw this.nestLimit(start);\n\n\t\tthis.heights.set(value, height);\n\t\treturn value;\n\t}\n\n\tprivate altHeight(alt: readonly (readonly Node[])[]): number {\n\t\tlet tallest = 0;\n\t\tfor (const branch of alt) for (const node of branch) tallest = Math.max(tallest, this.height(node));\n\n\t\treturn tallest;\n\t}\n\n\t/** A union is a level of its own only with two items or more: Rust folds a union of one item into that item. */\n\tprivate unionHeight(items: readonly ClassItem[]): number {\n\t\tlet tallest = 0;\n\t\tfor (const item of items) if (item.kind === 'class') tallest = Math.max(tallest, this.height(item.set));\n\n\t\treturn (items.length > 1 ? 1 : 0) + tallest;\n\t}\n\n\tprivate leave(): void {\n\t\tthis.depth--;\n\t}\n\n\tprivate readCodePoint(): number {\n\t\tconst cp = this.src.codePointAt(this.pos);\n\t\tif (cp === undefined) throw this.error('invalid_syntax', 'unexpected end of the pattern');\n\n\t\tthis.pos += cp > 0xffff ? 2 : 1;\n\t\treturn cp;\n\t}\n\n\t/**\n\t * In verbose mode (`(?x)`) whitespace and `#` comments are not part of the pattern. That holds inside a class and\n\t * a counted repetition too, where an escaped `\\#` is still a literal.\n\t */\n\tprivate skipVerbose(flags: Flags): void {\n\t\tif (!flags.x) return;\n\n\t\tfor (;;) {\n\t\t\tconst ch = this.src[this.pos];\n\t\t\tif (ch === undefined) return;\n\n\t\t\tif (ch === '#') {\n\t\t\t\twhile (this.pos < this.src.length && this.src[this.pos] !== '\\n') this.pos++;\n\t\t\t} else if (WHITESPACE.test(ch)) {\n\t\t\t\tthis.pos++;\n\t\t\t} else {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate parseAlternation(flags: Flags): Node[][] {\n\t\tconst branches: Node[][] = [];\n\t\tfor (;;) {\n\t\t\tbranches.push(this.parseConcat(flags));\n\t\t\tif (this.src[this.pos] !== '|') return branches;\n\n\t\t\tthis.pos++;\n\t\t}\n\t}\n\n\tprivate parseConcat(flags: Flags): Node[] {\n\t\tconst nodes: Node[] = [];\n\t\tfor (;;) {\n\t\t\tthis.skipVerbose(flags);\n\t\t\tconst ch = this.src[this.pos];\n\t\t\tif (ch === undefined || ch === '|' || ch === ')') return nodes;\n\n\t\t\tlet { node, repeatable } = this.parseAtom(flags);\n\n\t\t\tfor (;;) {\n\t\t\t\tthis.skipVerbose(flags);\n\t\t\t\tconst next = this.src[this.pos];\n\t\t\t\tif (next !== '*' && next !== '+' && next !== '?' && next !== '{') break;\n\t\t\t\tif (!repeatable) throw this.error('invalid_syntax', 'repetition operator missing expression');\n\n\t\t\t\tconst operand = node;\n\t\t\t\tconst operatorAt = this.pos;\n\t\t\t\tnode = this.withHeight(this.parseRepetition(flags, node), this.height(operand) + 1, operatorAt);\n\t\t\t\trepeatable = true;\n\t\t\t}\n\n\t\t\tnodes.push(node);\n\t\t}\n\t}\n\n\tprivate parseRepetition(flags: Flags, node: Node): Node {\n\t\tlet min: number;\n\t\tlet max: number | null;\n\n\t\tswitch (this.src[this.pos]) {\n\t\t\tcase '*':\n\t\t\t\tthis.pos++;\n\t\t\t\tmin = 0;\n\t\t\t\tmax = null;\n\t\t\t\tbreak;\n\t\t\tcase '+':\n\t\t\t\tthis.pos++;\n\t\t\t\tmin = 1;\n\t\t\t\tmax = null;\n\t\t\t\tbreak;\n\t\t\tcase '?':\n\t\t\t\tthis.pos++;\n\t\t\t\tmin = 0;\n\t\t\t\tmax = 1;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\t[min, max] = this.parseCounted(flags);\n\t\t}\n\n\t\tlet lazy = false;\n\t\tif (this.src[this.pos] === '?') {\n\t\t\tthis.pos++;\n\t\t\tlazy = true;\n\t\t}\n\n\t\t// `(?U)` swaps what a trailing `?` means.\n\t\treturn { type: 'repeat', min, max, lazy: lazy !== flags.U, node };\n\t}\n\n\tprivate parseCounted(flags: Flags): [min: number, max: number | null] {\n\t\tconst start = this.pos;\n\t\tthis.pos++; // {\n\t\tthis.skipVerbose(flags);\n\t\tconst min = this.readDecimal();\n\t\tthis.skipVerbose(flags);\n\n\t\tlet max: number | null = min;\n\t\tif (this.src[this.pos] === ',') {\n\t\t\tthis.pos++;\n\t\t\tthis.skipVerbose(flags);\n\t\t\tmax = this.src[this.pos] === '}' ? null : this.readDecimal();\n\t\t\tthis.skipVerbose(flags);\n\t\t}\n\n\t\tif (this.src[this.pos] !== '}') throw this.error('invalid_syntax', 'unclosed counted repetition', start);\n\n\t\tthis.pos++;\n\t\tif (max !== null && min > max) throw this.error('invalid_syntax', 'the minimum of a counted repetition is greater than its maximum', start);\n\n\t\treturn [min, max];\n\t}\n\n\tprivate readDecimal(): number {\n\t\tconst start = this.pos;\n\t\twhile (this.src[this.pos] !== undefined && this.src[this.pos]! >= '0' && this.src[this.pos]! <= '9') this.pos++;\n\n\t\tif (this.pos === start) throw this.error('invalid_syntax', 'a counted repetition expects a decimal number');\n\n\t\tconst value = Number(this.src.slice(start, this.pos));\n\t\tif (value > 0xffffffff) throw this.error('invalid_syntax', 'the number in a counted repetition is too big', start);\n\n\t\treturn value;\n\t}\n\n\tprivate parseAtom(flags: Flags): Parsed {\n\t\tswitch (this.src[this.pos]) {\n\t\t\tcase '(':\n\t\t\t\treturn this.parseGroup(flags);\n\t\t\tcase '[': {\n\t\t\t\tconst start = this.pos;\n\t\t\t\tconst set = this.parseBracket(flags);\n\n\t\t\t\t// Groups and repetitions look up the height of the node, not of the class set it wraps.\n\t\t\t\tconst node: Node = { type: 'class', set };\n\t\t\t\treturn { node: this.withHeight(node, this.height(set), start), repeatable: true };\n\t\t\t}\n\t\t\tcase '.':\n\t\t\t\tthis.pos++;\n\t\t\t\treturn { node: { type: 'dot', dotAll: flags.s }, repeatable: true };\n\t\t\tcase '^':\n\t\t\t\tthis.pos++;\n\t\t\t\treturn { node: { type: 'assertion', kind: flags.m ? 'line-start' : 'text-start' }, repeatable: true };\n\t\t\tcase '$':\n\t\t\t\tthis.pos++;\n\t\t\t\treturn { node: { type: 'assertion', kind: flags.m ? 'line-end' : 'text-end' }, repeatable: true };\n\t\t\tcase '\\\\': {\n\t\t\t\tconst escape = this.parseEscape(false);\n\t\t\t\tswitch (escape.kind) {\n\t\t\t\t\tcase 'char':\n\t\t\t\t\t\treturn { node: { type: 'literal', cp: escape.cp }, repeatable: true };\n\t\t\t\t\tcase 'item':\n\t\t\t\t\t\treturn { node: { type: 'class', set: { negated: false, expr: union([escape.item]) } }, repeatable: true };\n\t\t\t\t\tcase 'assertion':\n\t\t\t\t\t\treturn { node: { type: 'assertion', kind: escape.assertion }, repeatable: true };\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase '*':\n\t\t\tcase '+':\n\t\t\tcase '?':\n\t\t\tcase '{':\n\t\t\t\tthrow this.error('invalid_syntax', 'repetition operator missing expression');\n\t\t\tdefault:\n\t\t\t\treturn { node: { type: 'literal', cp: this.readCodePoint() }, repeatable: true };\n\t\t}\n\t}\n\n\tprivate parseGroup(flags: Flags): Parsed {\n\t\tconst start = this.pos;\n\t\tthis.pos++; // (\n\n\t\tif (this.src[this.pos] !== '?') return this.finishGroup(flags, start, true, undefined);\n\n\t\tthis.pos++; // ?\n\t\tswitch (this.src[this.pos]) {\n\t\t\tcase 'P': {\n\t\t\t\tconst after = this.src[this.pos + 1];\n\t\t\t\tif (after === '<') {\n\t\t\t\t\tthis.pos += 2;\n\t\t\t\t\treturn this.finishNamedGroup(flags, start);\n\t\t\t\t}\n\n\t\t\t\tif (after === '=') throw this.error('unsupported_backreference', 'backreferences are not supported by the Rust regex crate', start);\n\t\t\t\tif (after === '>') throw this.error('unsupported_feature', 'recursion is not supported by the Rust regex crate', start);\n\t\t\t\tthrow this.error('invalid_syntax', 'unrecognized group syntax', start);\n\t\t\t}\n\t\t\tcase '<': {\n\t\t\t\tconst after = this.src[this.pos + 1];\n\t\t\t\tif (after === '=' || after === '!')\n\t\t\t\t\tthrow this.error('unsupported_lookaround', 'lookbehind is not supported by the Rust regex crate', start);\n\n\t\t\t\tthis.pos++;\n\t\t\t\treturn this.finishNamedGroup(flags, start);\n\t\t\t}\n\t\t\tcase '=':\n\t\t\tcase '!':\n\t\t\t\tthrow this.error('unsupported_lookaround', 'lookahead is not supported by the Rust regex crate', start);\n\t\t\tcase '>':\n\t\t\t\tthrow this.error('unsupported_feature', 'atomic groups are not supported by the Rust regex crate', start);\n\t\t\tdefault:\n\t\t\t\treturn this.parseFlagsGroup(flags, start);\n\t\t}\n\t}\n\n\tprivate finishNamedGroup(flags: Flags, start: number): Parsed {\n\t\tconst end = this.src.indexOf('>', this.pos);\n\t\tif (end === -1) throw this.error('invalid_syntax', 'unclosed capture group name', start);\n\n\t\tconst name = this.src.slice(this.pos, end);\n\t\tif (name === '') throw this.error('invalid_syntax', 'a capture group name cannot be empty', start);\n\t\tif (!RUST_GROUP_NAME.test(name)) throw this.error('invalid_syntax', `the capture group name \"${name}\" is not valid`, start);\n\t\tif (!JS_GROUP_NAME.test(name)) throw this.error('unsupported_feature', `the capture group name \"${name}\" is not valid in JavaScript`, start);\n\n\t\tif (this.names.has(name)) throw this.error('invalid_syntax', `duplicate capture group name \"${name}\"`, start);\n\n\t\tthis.names.add(name);\n\t\tthis.pos = end + 1;\n\t\treturn this.finishGroup(flags, start, true, name);\n\t}\n\n\tprivate finishGroup(flags: Flags, start: number, capture: boolean, name: string | undefined): Parsed {\n\t\tconst inner: Flags = { ...flags };\n\t\tconst iStart = inner.i;\n\n\t\tthis.enter();\n\t\tconst alt = this.parseAlternation(inner);\n\t\tthis.leave();\n\n\t\tif (this.src[this.pos] !== ')') throw this.error('invalid_syntax', 'unclosed group', start);\n\n\t\tthis.pos++;\n\t\tconst group: Node = { type: 'group', capture, name, iStart, alt };\n\t\treturn { node: this.withHeight(group, 1 + this.altHeight(alt), start), repeatable: true };\n\t}\n\n\t/** `(?flags)`, which changes the flags until the end of the group, and `(?flags:...)`, which scopes them to its body. */\n\tprivate parseFlagsGroup(flags: Flags, start: number): Parsed {\n\t\tconst next: Flags = { ...flags };\n\t\tconst seen = new Set<string>();\n\t\tlet negated = false;\n\t\tlet afterNegation = 0;\n\n\t\tfor (;;) {\n\t\t\tconst ch = this.src[this.pos];\n\t\t\tif (ch === undefined) throw this.error('invalid_syntax', 'unclosed group', start);\n\t\t\tif (ch === ')' || ch === ':') break;\n\n\t\t\tthis.pos++;\n\t\t\tif (ch === '-') {\n\t\t\t\tif (negated) throw this.error('invalid_syntax', 'a flag group has more than one negation');\n\n\t\t\t\tnegated = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (negated) afterNegation++;\n\n\t\t\tswitch (ch) {\n\t\t\t\tcase 'i':\n\t\t\t\tcase 'm':\n\t\t\t\tcase 's':\n\t\t\t\tcase 'U':\n\t\t\t\tcase 'x':\n\t\t\t\t\tif (seen.has(ch)) throw this.error('invalid_syntax', `duplicate flag \"${ch}\"`);\n\n\t\t\t\t\tseen.add(ch);\n\t\t\t\t\tnext[ch] = !negated;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'u':\n\t\t\t\t\tif (negated) throw this.error('unsupported_feature', 'disabling Unicode mode with (?-u) cannot be expressed in JavaScript');\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'R':\n\t\t\t\t\tif (!negated) throw this.error('unsupported_feature', 'CRLF mode (?R) cannot be expressed in JavaScript');\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow this.error('invalid_syntax', `unrecognized flag \"${ch}\"`);\n\t\t\t}\n\t\t}\n\n\t\tif (negated && afterNegation === 0) throw this.error('invalid_syntax', 'a flag negation is missing the flags it negates');\n\n\t\tconst terminator = this.src[this.pos];\n\t\tif (terminator === ':') {\n\t\t\tthis.pos++;\n\t\t\tthis.enter();\n\t\t\tconst iStart = next.i;\n\t\t\tconst alt = this.parseAlternation(next);\n\t\t\tthis.leave();\n\n\t\t\tif (this.src[this.pos] !== ')') throw this.error('invalid_syntax', 'unclosed group', start);\n\n\t\t\tthis.pos++;\n\t\t\tconst group: Node = { type: 'group', capture: false, name: undefined, iStart, alt };\n\t\t\treturn { node: this.withHeight(group, 1 + this.altHeight(alt), start), repeatable: true };\n\t\t}\n\n\t\tif (seen.size === 0 && !negated && this.src[this.pos - 1] === '?')\n\t\t\tthrow this.error('invalid_syntax', 'a flag group is missing its flags', start);\n\n\t\tthis.pos++; // )\n\t\tObject.assign(flags, next);\n\t\treturn { node: { type: 'flags', i: flags.i }, repeatable: false };\n\t}\n\n\tprivate parseBracket(flags: Flags): ClassSet {\n\t\tconst start = this.pos;\n\t\tthis.pos++; // [\n\t\tthis.enter();\n\n\t\tlet negated = false;\n\t\tif (this.src[this.pos] === '^') {\n\t\t\tnegated = true;\n\t\t\tthis.pos++;\n\t\t}\n\n\t\tlet lhs: ClassExpr | null = null;\n\t\tlet lhsHeight = 0;\n\t\tlet op: ClassOp | null = null;\n\t\tlet items: ClassItem[] = [];\n\t\tlet first = true;\n\n\t\tfor (;;) {\n\t\t\tthis.skipVerbose(flags);\n\t\t\tconst ch = this.src[this.pos];\n\t\t\tif (ch === undefined) throw this.error('invalid_syntax', 'unclosed character class', start);\n\n\t\t\tif (ch === ']' && !first) {\n\t\t\t\tthis.pos++;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tfirst = false;\n\n\t\t\tconst operator = this.src.startsWith('&&', this.pos)\n\t\t\t\t? '&&'\n\t\t\t\t: this.src.startsWith('--', this.pos)\n\t\t\t\t\t? '--'\n\t\t\t\t\t: this.src.startsWith('~~', this.pos)\n\t\t\t\t\t\t? '~~'\n\t\t\t\t\t\t: null;\n\t\t\tif (operator !== null) {\n\t\t\t\tif (items.length === 0) throw this.error('invalid_syntax', `the \"${operator}\" operator is missing its left operand`);\n\n\t\t\t\tconst operand = union(items);\n\t\t\t\tconst operandHeight = this.unionHeight(items);\n\t\t\t\tif (lhs === null || op === null) {\n\t\t\t\t\tlhs = operand;\n\t\t\t\t\tlhsHeight = operandHeight;\n\t\t\t\t} else {\n\t\t\t\t\tlhs = { kind: 'binary', op, left: lhs, right: operand };\n\t\t\t\t\tlhsHeight = 1 + Math.max(lhsHeight, operandHeight);\n\t\t\t\t\tif (lhsHeight > NEST_LIMIT) throw this.nestLimit(start);\n\t\t\t\t}\n\n\t\t\t\top = operator;\n\t\t\t\titems = [];\n\t\t\t\tthis.pos += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ch === '[') {\n\t\t\t\titems.push(this.tryAsciiClass() ?? { kind: 'class', set: this.parseBracket(flags) });\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (ch === '\\\\') {\n\t\t\t\tconst escape = this.parseEscape(true);\n\t\t\t\tif (escape.kind === 'item') items.push(escape.item);\n\t\t\t\telse if (escape.kind === 'char') this.pushCharOrRange(items, escape.cp, flags);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.pushCharOrRange(items, this.readCodePoint(), flags);\n\t\t}\n\n\t\tthis.leave();\n\n\t\tif (items.length === 0)\n\t\t\tthrow this.error('invalid_syntax', op === null ? 'empty character class' : `the \"${op}\" operator is missing its right operand`, start);\n\n\t\tconst lastHeight = this.unionHeight(items);\n\t\tconst expr: ClassExpr = lhs === null || op === null ? union(items) : { kind: 'binary', op, left: lhs, right: union(items) };\n\t\tconst exprHeight = lhs === null || op === null ? lastHeight : 1 + Math.max(lhsHeight, lastHeight);\n\n\t\treturn this.withHeight({ negated, expr }, 1 + exprHeight, start);\n\t}\n\n\t/** In verbose mode (`(?x)`) whitespace may sit on either side of the dash, as in `[a - z]`. */\n\tprivate pushCharOrRange(items: ClassItem[], lo: number, flags: Flags): void {\n\t\tconst afterLo = this.pos;\n\t\tthis.skipVerbose(flags);\n\n\t\tconst dashAt = this.pos;\n\t\tconst joinsRange = this.src[dashAt] === '-' && this.src[dashAt + 1] !== '-';\n\t\tif (joinsRange) {\n\t\t\tthis.pos++; // -\n\t\t\tthis.skipVerbose(flags);\n\t\t}\n\n\t\tconst next = this.src[this.pos];\n\t\t// Rust looks past whitespace for the `]` or the `-` that follows the dash, so `[a - -]` is `a` and `-`.\n\t\tif (!joinsRange || next === undefined || next === ']' || next === '-') {\n\t\t\t// Not a range: the dash, if any, is read again as a character of its own.\n\t\t\tthis.pos = afterLo;\n\t\t\titems.push({ kind: 'char', cp: lo });\n\t\t\treturn;\n\t\t}\n\n\t\tlet hi: number;\n\t\tif (this.src[this.pos] === '\\\\') {\n\t\t\tconst escape = this.parseEscape(true);\n\t\t\tif (escape.kind !== 'char') throw this.error('invalid_syntax', 'the end of a range must be a single character');\n\n\t\t\thi = escape.cp;\n\t\t} else if (this.src[this.pos] === '[') {\n\t\t\tthrow this.error('invalid_syntax', 'the end of a range must be a single character');\n\t\t} else {\n\t\t\thi = this.readCodePoint();\n\t\t}\n\n\t\tif (hi < lo) throw this.error('invalid_syntax', 'invalid range: the start is greater than the end');\n\n\t\titems.push({ kind: 'range', lo, hi });\n\t}\n\n\t/** `[:alpha:]`, `[:^alpha:]`: only meaningful directly inside a bracketed class. */\n\tprivate tryAsciiClass(): ClassItem | null {\n\t\tASCII_CLASS.lastIndex = this.pos;\n\t\tconst match = ASCII_CLASS.exec(this.src);\n\t\tif (match === null) return null;\n\n\t\tconst [whole = '', caret = '', name = ''] = match;\n\t\tconst ranges = ASCII_CLASSES[name];\n\t\tif (ranges === undefined) throw this.error('invalid_syntax', `unrecognized ASCII class \"${name}\"`);\n\n\t\tthis.pos += whole.length;\n\t\treturn { kind: 'class', set: { negated: caret === '^', expr: union(ranges.map(([lo, hi]): ClassItem => ({ kind: 'range', lo, hi }))) } };\n\t}\n\n\tprivate parseEscape(inClass: boolean): Escape {\n\t\tconst start = this.pos;\n\t\tthis.pos++; // backslash\n\n\t\tif (this.pos >= this.src.length) throw this.error('invalid_syntax', 'incomplete escape sequence: the pattern ends after a backslash', start);\n\n\t\tconst cp = this.readCodePoint();\n\t\tconst ch = String.fromCodePoint(cp);\n\n\t\tswitch (ch) {\n\t\t\tcase 't':\n\t\t\t\treturn { kind: 'char', cp: 0x09 };\n\t\t\tcase 'n':\n\t\t\t\treturn { kind: 'char', cp: 0x0a };\n\t\t\tcase 'r':\n\t\t\t\treturn { kind: 'char', cp: 0x0d };\n\t\t\tcase 'f':\n\t\t\t\treturn { kind: 'char', cp: 0x0c };\n\t\t\tcase 'v':\n\t\t\t\treturn { kind: 'char', cp: 0x0b };\n\t\t\tcase 'a':\n\t\t\t\treturn { kind: 'char', cp: 0x07 };\n\t\t\tcase 'x':\n\t\t\t\treturn { kind: 'char', cp: this.parseHex(2, start) };\n\t\t\tcase 'u':\n\t\t\t\treturn { kind: 'char', cp: this.parseHex(4, start) };\n\t\t\tcase 'U':\n\t\t\t\treturn { kind: 'char', cp: this.parseHex(8, start) };\n\t\t\tcase 'd':\n\t\t\tcase 's':\n\t\t\tcase 'w':\n\t\t\t\treturn { kind: 'item', item: { kind: 'perl', cls: ch, negated: false } };\n\t\t\tcase 'D':\n\t\t\tcase 'S':\n\t\t\tcase 'W':\n\t\t\t\treturn { kind: 'item', item: { kind: 'perl', cls: ch.toLowerCase() as PerlClass, negated: true } };\n\t\t\tcase 'p':\n\t\t\tcase 'P':\n\t\t\t\treturn { kind: 'item', item: this.parseProperty(ch === 'P', start) };\n\t\t\tcase 'A':\n\t\t\tcase 'z':\n\t\t\tcase 'B':\n\t\t\t\treturn this.assertion(ch === 'A' ? 'text-start' : ch === 'z' ? 'text-end' : 'not-word-boundary', inClass, start);\n\t\t\tcase 'b':\n\t\t\t\tif (this.src[this.pos] === '{') throw this.error('unsupported_feature', 'the \\\\b{...} word boundaries are not supported', start);\n\n\t\t\t\treturn this.assertion('word-boundary', inClass, start);\n\t\t\tcase '<':\n\t\t\tcase '>':\n\t\t\t\tthrow this.error('unsupported_feature', `the \\\\${ch} word boundary is not supported`, start);\n\t\t\tcase 'k':\n\t\t\t\tif (this.src[this.pos] === '<')\n\t\t\t\t\tthrow this.error('unsupported_backreference', 'backreferences are not supported by the Rust regex crate', start);\n\n\t\t\t\tthrow this.error('invalid_syntax', 'unrecognized escape sequence \"\\\\k\"', start);\n\t\t\tdefault:\n\t\t\t\tif (ch >= '1' && ch <= '9')\n\t\t\t\t\tthrow this.error('unsupported_backreference', 'backreferences are not supported by the Rust regex crate', start);\n\t\t\t\tif (ch === '0') throw this.error('invalid_syntax', 'octal escapes are not supported, use \\\\x00', start);\n\n\t\t\t\t// Anything that is ASCII and not a letter or a digit is a literal when escaped.\n\t\t\t\tif (cp < 0x80 && !isAsciiAlphanumeric(ch)) return { kind: 'char', cp };\n\n\t\t\t\tthrow this.error('invalid_syntax', `unrecognized escape sequence \"\\\\${ch}\"`, start);\n\t\t}\n\t}\n\n\tprivate assertion(kind: AssertionKind, inClass: boolean, start: number): Escape {\n\t\tif (inClass) throw this.error('invalid_syntax', 'an assertion is not allowed in a character class', start);\n\n\t\treturn { kind: 'assertion', assertion: kind };\n\t}\n\n\t/** `\\xNN`, `\\x{N...}`, `\\uNNNN`, `\\u{N...}`, `\\UNNNNNNNN`, `\\U{N...}`. */\n\tprivate parseHex(digits: number, start: number): number {\n\t\tlet text: string;\n\t\tif (this.src[this.pos] === '{') {\n\t\t\tconst end = this.src.indexOf('}', this.pos);\n\t\t\tif (end === -1) throw this.error('invalid_syntax', 'unclosed hexadecimal escape', start);\n\n\t\t\ttext = this.src.slice(this.pos + 1, end).trim();\n\t\t\tthis.pos = end + 1;\n\t\t\tif (!/^[0-9A-Fa-f]{1,8}$/.test(text)) throw this.error('invalid_syntax', 'invalid hexadecimal escape', start);\n\t\t} else {\n\t\t\ttext = this.src.slice(this.pos, this.pos + digits);\n\t\t\tif (text.length !== digits || !/^[0-9A-Fa-f]+$/.test(text))\n\t\t\t\tthrow this.error('invalid_syntax', `a hexadecimal escape needs exactly ${digits} digits`, start);\n\n\t\t\tthis.pos += digits;\n\t\t}\n\n\t\tconst cp = Number.parseInt(text, 16);\n\t\tif (cp > MAX_CODE_POINT || (cp >= 0xd800 && cp <= 0xdfff))\n\t\t\tthrow this.error('invalid_syntax', 'a hexadecimal escape must be a Unicode scalar value', start);\n\n\t\treturn cp;\n\t}\n\n\tprivate parseProperty(negated: boolean, start: number): ClassItem {\n\t\tlet spec: string;\n\t\tlet singleLetter = false;\n\n\t\tif (this.src[this.pos] === '{') {\n\t\t\tconst end = this.src.indexOf('}', this.pos);\n\t\t\tif (end === -1) throw this.error('invalid_syntax', 'unclosed Unicode class', start);\n\n\t\t\tspec = this.src.slice(this.pos + 1, end).trim();\n\t\t\tthis.pos = end + 1;\n\t\t} else {\n\t\t\tspec = this.src[this.pos] ?? '';\n\t\t\tif (spec === '') throw this.error('invalid_syntax', 'incomplete Unicode class: the pattern ends after \\\\p', start);\n\n\t\t\tthis.pos++;\n\t\t\tsingleLetter = true;\n\t\t}\n\n\t\tif (spec.startsWith('^')) {\n\t\t\tnegated = !negated;\n\t\t\tspec = spec.slice(1).trim();\n\t\t}\n\n\t\tconst resolved = resolveProperty(spec, singleLetter);\n\t\tif ('error' in resolved)\n\t\t\tthrow this.error(resolved.error === 'unsupported' ? 'unsupported_feature' : 'invalid_syntax', resolved.message, start);\n\n\t\treturn { kind: 'property', expr: resolved.expr, negated: negated !== resolved.negated };\n\t}\n}\n\nexport function parse(pattern: string, flags: Flags): ParseResult {\n\t// The parser changes `flags` as it meets `(?i)`, so the state the pattern starts in is read first.\n\tlet initialI = flags.i;\n\tconst alt = new Parser(pattern).parse(flags);\n\n\t// A flag group at the very start of the pattern applies to all of it, so it becomes the starting state instead of\n\t// a scoped `(?i:...)` around everything.\n\tconst first = alt[0];\n\twhile (first !== undefined && first[0]?.type === 'flags') {\n\t\tinitialI = first[0].i;\n\t\tfirst.shift();\n\t}\n\n\treturn { alt, initialI };\n}\n","import { Emitter } from './emitter.js';\nimport { RustRegexError } from './errors.js';\nimport { parse, type Flags } from './parser.js';\n\nexport interface TranspileOptions {\n\t/**\n\t * The Rust flags the pattern starts with, as if it began with `(?flags)`. Any of `i`, `m`, `s`, `x` and `U`.\n\t *\n\t * @default ''\n\t */\n\tflags?: string;\n\n\t/**\n\t * Whether to compile the result to prove the JavaScript engine accepts it. This is what reports an unknown Unicode\n\t * script name, or scoped flags on a runtime without ES2025 regular expression modifiers.\n\t *\n\t * @default true\n\t */\n\tvalidate?: boolean;\n}\n\nexport interface TranspileResult {\n\t/** The pattern, for `new RegExp(source, flags)`. */\n\treadonly source: string;\n\n\t/** The flags to compile {@link TranspileResult.source} with: always `v`, plus `i` when the Rust pattern is case-insensitive. */\n\treadonly flags: string;\n\n\t/** Whether {@link TranspileResult.source} contains `(?i:...)` or `(?-i:...)`, which need ES2025 (Node.js 23 or newer). */\n\treadonly usesModifiers: boolean;\n}\n\nexport interface ToRegExpOptions extends TranspileOptions {\n\t/** Flags added to the ones the pattern needs: any of `d`, `g` and `y`. The others would change what the Rust pattern means. */\n\textraFlags?: string;\n}\n\n/**\n * The JavaScript flags a caller may add. `i`, `m`, `s` and `u` would change what the Rust pattern means, and `v` is\n * always set, so none of them can be added.\n */\nconst EXTRA_FLAGS = new Set(['d', 'g', 'y']);\n\nfunction checkExtraFlags(extraFlags: string, pattern: string): void {\n\tconst seen = new Set<string>();\n\tfor (const flag of extraFlags) {\n\t\tif (!EXTRA_FLAGS.has(flag)) {\n\t\t\tthrow new RustRegexError('invalid_option', `extraFlags accepts only \"d\", \"g\" and \"y\", not \"${flag}\"`, pattern);\n\t\t}\n\n\t\tif (seen.has(flag)) throw new RustRegexError('invalid_option', `extraFlags repeats the flag \"${flag}\"`, pattern);\n\n\t\tseen.add(flag);\n\t}\n}\n\nfunction parseFlags(flags: string, pattern: string): Flags {\n\tconst result: Flags = { i: false, m: false, s: false, U: false, x: false };\n\tfor (const flag of flags) {\n\t\tif (flag !== 'i' && flag !== 'm' && flag !== 's' && flag !== 'U' && flag !== 'x') {\n\t\t\tthrow new RustRegexError('invalid_option', `unrecognized flag \"${flag}\"`, pattern);\n\t\t}\n\n\t\tresult[flag] = true;\n\t}\n\n\treturn result;\n}\n\n/**\n * Converts a regular expression written for the Rust `regex` crate, the flavour Discord uses, into the source and\n * flags of an equivalent JavaScript `RegExp`.\n *\n * @example\n * ```ts\n * transpile(String.raw`(?i)\\bfree\\s+nitro\\b`);\n * // { source: '(?:(?<=[…])(?![…])|…)free\\\\p{White_Space}+nitro…', flags: 'iv', usesModifiers: false }\n * ```\n *\n * @throws {RustRegexError} When Rust would reject the pattern, or when it uses something JavaScript cannot express.\n */\nexport function transpile(pattern: string, options: TranspileOptions = {}): TranspileResult {\n\tconst { alt, initialI } = parse(pattern, parseFlags(options.flags ?? '', pattern));\n\tconst { source, usesModifiers } = new Emitter(pattern).emit(alt, initialI);\n\tconst flags = initialI ? 'iv' : 'v';\n\n\tif (options.validate !== false) {\n\t\ttry {\n\t\t\tnew RegExp(source, flags);\n\t\t} catch (error) {\n\t\t\tthrow new RustRegexError('invalid_output', rejection(error, usesModifiers), pattern);\n\t\t}\n\t}\n\n\treturn { source, flags, usesModifiers };\n}\n\nfunction rejection(error: unknown, usesModifiers: boolean): string {\n\tconst hint = usesModifiers ? ' (scoped flags need a runtime with ES2025 regular expression modifiers)' : '';\n\treturn `JavaScript rejected the translated pattern: ${error instanceof Error ? error.message : String(error)}${hint}`;\n}\n\n/**\n * Same as {@link transpile}, but returns the compiled `RegExp`.\n *\n * Rust matches in time linear in the size of the text, whatever the pattern. A JavaScript `RegExp` backtracks, so a\n * pattern such as `(a+)+$` that is safe in Rust can take exponential time here. Do not run the result against text a\n * stranger controls without a limit, for example in a worker with a timeout.\n *\n * @example\n * ```ts\n * toRegExp(String.raw`(?P<year>\\d{4})-(?P<month>\\d{2})`).exec('2026-11')?.groups?.year; // '2026'\n * ```\n */\nexport function toRegExp(pattern: string, options: ToRegExpOptions = {}): RegExp {\n\tconst { extraFlags = '', ...rest } = options;\n\tcheckExtraFlags(extraFlags, pattern);\n\n\tconst { source, flags, usesModifiers } = transpile(pattern, { ...rest, validate: false });\n\n\ttry {\n\t\treturn new RegExp(source, flags + extraFlags);\n\t} catch (error) {\n\t\tthrow new RustRegexError('invalid_output', rejection(error, usesModifiers), pattern);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,iBAAb,cAAoC,YAAY;CAaxC,YAAY,MAA0B,SAAiB,SAAiB,UAAmB;EACjG,MAAM,aAAa,SAAY,GAAG,QAAQ,QAAQ,QAAQ,MAAM,GAAG,QAAQ,aAAa,SAAS,OAAO,QAAQ,GAAG;wBAZpG;wBAGA;wBAMA;EAIf,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,UAAU;EACf,KAAK,WAAW;CACjB;AACD;;;;;;;ACpCA,MAAM,eAAe,OAAO,GAAG;AAC/B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O;EAAE;EAAQ;EAAO;CAAc;AACvC;AAEA,SAAS,UAAU,OAAgB,eAAgC;CAClE,MAAM,OAAO,gBAAgB,4EAA4E;CACzG,OAAO,+CAA+C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,IAAI;AAChH;;;;;;;;;;;;;AAcA,SAAgB,SAAS,SAAiB,UAA2B,CAAC,GAAW;CAChF,MAAM,EAAE,aAAa,IAAI,GAAG,SAAS;CACrC,gBAAgB,YAAY,OAAO;CAEnC,MAAM,EAAE,QAAQ,OAAO,kBAAkB,UAAU,SAAS;EAAE,GAAG;EAAM,UAAU;CAAM,CAAC;CAExF,IAAI;EACH,OAAO,IAAI,OAAO,QAAQ,QAAQ,UAAU;CAC7C,SAAS,OAAO;EACf,MAAM,IAAI,eAAe,kBAAkB,UAAU,OAAO,aAAa,GAAG,OAAO;CACpF;AACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wolfstar/rust-regex",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Transpiles regular expressions written for the Rust regex crate, the flavour Discord uses, into JavaScript RegExp",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"automod",
|
|
7
|
+
"discord",
|
|
8
|
+
"regex",
|
|
9
|
+
"regexp",
|
|
10
|
+
"rust",
|
|
11
|
+
"transpiler",
|
|
12
|
+
"wolfstar"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/wolfstar-project/stars-components/tree/main/packages/rust-regex",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/wolfstar-project/stars-components/issues"
|
|
17
|
+
},
|
|
18
|
+
"license": "Apache-2.0",
|
|
19
|
+
"author": "@wolfstar",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/wolfstar-project/stars-components.git",
|
|
23
|
+
"directory": "packages/rust-regex"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist/"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"main": "dist/esm/index.js",
|
|
31
|
+
"module": "dist/esm/index.js",
|
|
32
|
+
"types": "dist/esm/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/esm/index.d.ts",
|
|
37
|
+
"default": "./dist/esm/index.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"provenance": true
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@vitest/coverage-v8": "^5.1.2",
|
|
48
|
+
"golar": "^0.1.11",
|
|
49
|
+
"tsdown": "^0.23.7",
|
|
50
|
+
"typescript": "~7.0.2",
|
|
51
|
+
"vitest": "^5.1.2"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=20"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"build": "tsdown --config-loader unrun",
|
|
59
|
+
"watch": "tsdown --config-loader unrun --watch",
|
|
60
|
+
"typecheck": "golar tsc -p ../../tsconfig.json",
|
|
61
|
+
"lint": "oxlint src --fix"
|
|
62
|
+
}
|
|
6
63
|
}
|