oxlint-plugin-eslint 1.52.0
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 +22 -0
- package/README.md +36 -0
- package/common/ast-utils.cjs +5843 -0
- package/common/chunk.cjs +9 -0
- package/common/eslint-utils.cjs +1633 -0
- package/common/fix-tracker.cjs +89 -0
- package/common/ignore.cjs +123 -0
- package/common/keywords.cjs +15 -0
- package/common/regexpp.cjs +1720 -0
- package/common/regular-expressions.cjs +40 -0
- package/common/string-utils.cjs +39 -0
- package/index.js +7477 -0
- package/package.json +34 -0
- package/rules/accessor-pairs.cjs +233 -0
- package/rules/array-bracket-newline.cjs +172 -0
- package/rules/array-bracket-spacing.cjs +184 -0
- package/rules/array-callback-return.cjs +262 -0
- package/rules/array-element-newline.cjs +178 -0
- package/rules/arrow-body-style.cjs +135 -0
- package/rules/arrow-parens.cjs +130 -0
- package/rules/arrow-spacing.cjs +129 -0
- package/rules/block-scoped-var.cjs +101 -0
- package/rules/block-spacing.cjs +125 -0
- package/rules/brace-style.cjs +141 -0
- package/rules/callback-return.cjs +117 -0
- package/rules/camelcase.cjs +194 -0
- package/rules/capitalized-comments.cjs +168 -0
- package/rules/class-methods-use-this.cjs +155 -0
- package/rules/comma-dangle.cjs +274 -0
- package/rules/comma-spacing.cjs +111 -0
- package/rules/comma-style.cjs +180 -0
- package/rules/complexity.cjs +100 -0
- package/rules/computed-property-spacing.cjs +155 -0
- package/rules/consistent-return.cjs +113 -0
- package/rules/consistent-this.cjs +109 -0
- package/rules/constructor-super.cjs +207 -0
- package/rules/curly.cjs +173 -0
- package/rules/default-case-last.cjs +36 -0
- package/rules/default-case.cjs +50 -0
- package/rules/default-param-last.cjs +61 -0
- package/rules/dot-location.cjs +87 -0
- package/rules/dot-notation.cjs +77 -0
- package/rules/eol-last.cjs +91 -0
- package/rules/eqeqeq.cjs +127 -0
- package/rules/for-direction.cjs +94 -0
- package/rules/func-call-spacing.cjs +127 -0
- package/rules/func-name-matching.cjs +138 -0
- package/rules/func-names.cjs +121 -0
- package/rules/func-style.cjs +103 -0
- package/rules/function-call-argument-newline.cjs +109 -0
- package/rules/function-paren-newline.cjs +173 -0
- package/rules/generator-star-spacing.cjs +174 -0
- package/rules/getter-return.cjs +129 -0
- package/rules/global-require.cjs +84 -0
- package/rules/grouped-accessor-pairs.cjs +146 -0
- package/rules/guard-for-in.cjs +39 -0
- package/rules/handle-callback-err.cjs +86 -0
- package/rules/id-blacklist.cjs +135 -0
- package/rules/id-denylist.cjs +126 -0
- package/rules/id-length.cjs +119 -0
- package/rules/id-match.cjs +139 -0
- package/rules/implicit-arrow-linebreak.cjs +76 -0
- package/rules/indent-legacy.cjs +520 -0
- package/rules/indent.cjs +842 -0
- package/rules/init-declarations.cjs +88 -0
- package/rules/jsx-quotes.cjs +84 -0
- package/rules/key-spacing.cjs +399 -0
- package/rules/keyword-spacing.cjs +464 -0
- package/rules/line-comment-position.cjs +75 -0
- package/rules/linebreak-style.cjs +89 -0
- package/rules/lines-around-comment.cjs +290 -0
- package/rules/lines-around-directive.cjs +129 -0
- package/rules/lines-between-class-members.cjs +212 -0
- package/rules/logical-assignment-operators.cjs +305 -0
- package/rules/max-classes-per-file.cjs +61 -0
- package/rules/max-depth.cjs +117 -0
- package/rules/max-len.cjs +256 -0
- package/rules/max-lines-per-function.cjs +116 -0
- package/rules/max-lines.cjs +109 -0
- package/rules/max-nested-callbacks.cjs +78 -0
- package/rules/max-params.cjs +78 -0
- package/rules/max-statements-per-line.cjs +147 -0
- package/rules/max-statements.cjs +119 -0
- package/rules/multiline-comment-style.cjs +319 -0
- package/rules/multiline-ternary.cjs +106 -0
- package/rules/new-cap.cjs +139 -0
- package/rules/new-parens.cjs +70 -0
- package/rules/newline-after-var.cjs +159 -0
- package/rules/newline-before-return.cjs +128 -0
- package/rules/newline-per-chained-call.cjs +100 -0
- package/rules/no-alert.cjs +84 -0
- package/rules/no-array-constructor.cjs +91 -0
- package/rules/no-async-promise-executor.cjs +33 -0
- package/rules/no-await-in-loop.cjs +75 -0
- package/rules/no-bitwise.cjs +106 -0
- package/rules/no-buffer-constructor.cjs +51 -0
- package/rules/no-caller.cjs +34 -0
- package/rules/no-case-declarations.cjs +56 -0
- package/rules/no-catch-shadow.cjs +57 -0
- package/rules/no-class-assign.cjs +55 -0
- package/rules/no-compare-neg-zero.cjs +52 -0
- package/rules/no-cond-assign.cjs +104 -0
- package/rules/no-confusing-arrow.cjs +87 -0
- package/rules/no-console.cjs +138 -0
- package/rules/no-const-assign.cjs +50 -0
- package/rules/no-constant-binary-expression.cjs +284 -0
- package/rules/no-constant-condition.cjs +119 -0
- package/rules/no-constructor-return.cjs +43 -0
- package/rules/no-continue.cjs +33 -0
- package/rules/no-control-regex.cjs +74 -0
- package/rules/no-debugger.cjs +33 -0
- package/rules/no-delete-var.cjs +32 -0
- package/rules/no-div-regex.cjs +39 -0
- package/rules/no-dupe-args.cjs +61 -0
- package/rules/no-dupe-class-members.cjs +77 -0
- package/rules/no-dupe-else-if.cjs +74 -0
- package/rules/no-dupe-keys.cjs +88 -0
- package/rules/no-duplicate-case.cjs +49 -0
- package/rules/no-duplicate-imports.cjs +166 -0
- package/rules/no-else-return.cjs +182 -0
- package/rules/no-empty-character-class.cjs +47 -0
- package/rules/no-empty-function.cjs +141 -0
- package/rules/no-empty-pattern.cjs +50 -0
- package/rules/no-empty-static-block.cjs +50 -0
- package/rules/no-empty.cjs +78 -0
- package/rules/no-eq-null.cjs +34 -0
- package/rules/no-eval.cjs +165 -0
- package/rules/no-ex-assign.cjs +45 -0
- package/rules/no-extend-native.cjs +103 -0
- package/rules/no-extra-bind.cjs +127 -0
- package/rules/no-extra-boolean-cast.cjs +159 -0
- package/rules/no-extra-label.cjs +116 -0
- package/rules/no-extra-parens.cjs +665 -0
- package/rules/no-extra-semi.cjs +103 -0
- package/rules/no-fallthrough.cjs +136 -0
- package/rules/no-floating-decimal.cjs +66 -0
- package/rules/no-func-assign.cjs +63 -0
- package/rules/no-global-assign.cjs +62 -0
- package/rules/no-implicit-coercion.cjs +219 -0
- package/rules/no-implicit-globals.cjs +77 -0
- package/rules/no-implied-eval.cjs +87 -0
- package/rules/no-import-assign.cjs +123 -0
- package/rules/no-inline-comments.cjs +57 -0
- package/rules/no-inner-declarations.cjs +82 -0
- package/rules/no-invalid-regexp.cjs +130 -0
- package/rules/no-invalid-this.cjs +90 -0
- package/rules/no-irregular-whitespace.cjs +157 -0
- package/rules/no-iterator.cjs +34 -0
- package/rules/no-label-var.cjs +46 -0
- package/rules/no-labels.cjs +106 -0
- package/rules/no-lone-blocks.cjs +75 -0
- package/rules/no-lonely-if.cjs +42 -0
- package/rules/no-loop-func.cjs +143 -0
- package/rules/no-loss-of-precision.cjs +160 -0
- package/rules/no-magic-numbers.cjs +222 -0
- package/rules/no-misleading-character-class.cjs +500 -0
- package/rules/no-mixed-operators.cjs +197 -0
- package/rules/no-mixed-requires.cjs +117 -0
- package/rules/no-mixed-spaces-and-tabs.cjs +87 -0
- package/rules/no-multi-assign.cjs +38 -0
- package/rules/no-multi-spaces.cjs +95 -0
- package/rules/no-multi-str.cjs +44 -0
- package/rules/no-multiple-empty-lines.cjs +112 -0
- package/rules/no-native-reassign.cjs +72 -0
- package/rules/no-negated-condition.cjs +77 -0
- package/rules/no-negated-in-lhs.cjs +43 -0
- package/rules/no-nested-ternary.cjs +33 -0
- package/rules/no-new-func.cjs +50 -0
- package/rules/no-new-native-nonconstructor.cjs +42 -0
- package/rules/no-new-object.cjs +47 -0
- package/rules/no-new-require.cjs +50 -0
- package/rules/no-new-symbol.cjs +48 -0
- package/rules/no-new-wrappers.cjs +44 -0
- package/rules/no-new.cjs +33 -0
- package/rules/no-nonoctal-decimal-escape.cjs +80 -0
- package/rules/no-obj-calls.cjs +64 -0
- package/rules/no-object-constructor.cjs +69 -0
- package/rules/no-octal-escape.cjs +35 -0
- package/rules/no-octal.cjs +32 -0
- package/rules/no-param-reassign.cjs +135 -0
- package/rules/no-path-concat.cjs +52 -0
- package/rules/no-plusplus.cjs +64 -0
- package/rules/no-process-env.cjs +51 -0
- package/rules/no-process-exit.cjs +50 -0
- package/rules/no-promise-executor-return.cjs +131 -0
- package/rules/no-proto.cjs +34 -0
- package/rules/no-prototype-builtins.cjs +85 -0
- package/rules/no-redeclare.cjs +103 -0
- package/rules/no-regex-spaces.cjs +115 -0
- package/rules/no-restricted-exports.cjs +117 -0
- package/rules/no-restricted-globals.cjs +147 -0
- package/rules/no-restricted-imports.cjs +421 -0
- package/rules/no-restricted-modules.cjs +144 -0
- package/rules/no-restricted-properties.cjs +123 -0
- package/rules/no-restricted-syntax.cjs +49 -0
- package/rules/no-return-assign.cjs +45 -0
- package/rules/no-return-await.cjs +88 -0
- package/rules/no-script-url.cjs +49 -0
- package/rules/no-self-assign.cjs +88 -0
- package/rules/no-self-compare.cjs +53 -0
- package/rules/no-sequences.cjs +81 -0
- package/rules/no-setter-return.cjs +110 -0
- package/rules/no-shadow-restricted-names.cjs +60 -0
- package/rules/no-shadow.cjs +302 -0
- package/rules/no-spaced-func.cjs +69 -0
- package/rules/no-sparse-arrays.cjs +40 -0
- package/rules/no-sync.cjs +58 -0
- package/rules/no-tabs.cjs +73 -0
- package/rules/no-template-curly-in-string.cjs +33 -0
- package/rules/no-ternary.cjs +33 -0
- package/rules/no-this-before-super.cjs +177 -0
- package/rules/no-throw-literal.cjs +40 -0
- package/rules/no-trailing-spaces.cjs +123 -0
- package/rules/no-unassigned-vars.cjs +54 -0
- package/rules/no-undef-init.cjs +46 -0
- package/rules/no-undef.cjs +51 -0
- package/rules/no-undefined.cjs +58 -0
- package/rules/no-underscore-dangle.cjs +211 -0
- package/rules/no-unexpected-multiline.cjs +76 -0
- package/rules/no-unmodified-loop-condition.cjs +849 -0
- package/rules/no-unneeded-ternary.cjs +112 -0
- package/rules/no-unreachable-loop.cjs +128 -0
- package/rules/no-unreachable.cjs +195 -0
- package/rules/no-unsafe-finally.cjs +67 -0
- package/rules/no-unsafe-negation.cjs +86 -0
- package/rules/no-unsafe-optional-chaining.cjs +164 -0
- package/rules/no-unused-expressions.cjs +163 -0
- package/rules/no-unused-labels.cjs +97 -0
- package/rules/no-unused-private-class-members.cjs +69 -0
- package/rules/no-unused-vars.cjs +639 -0
- package/rules/no-use-before-define.cjs +245 -0
- package/rules/no-useless-assignment.cjs +250 -0
- package/rules/no-useless-backreference.cjs +137 -0
- package/rules/no-useless-call.cjs +57 -0
- package/rules/no-useless-catch.cjs +38 -0
- package/rules/no-useless-computed-key.cjs +106 -0
- package/rules/no-useless-concat.cjs +78 -0
- package/rules/no-useless-constructor.cjs +152 -0
- package/rules/no-useless-escape.cjs +164 -0
- package/rules/no-useless-rename.cjs +94 -0
- package/rules/no-useless-return.cjs +229 -0
- package/rules/no-var.cjs +235 -0
- package/rules/no-void.cjs +39 -0
- package/rules/no-warning-comments.cjs +112 -0
- package/rules/no-whitespace-before-property.cjs +72 -0
- package/rules/no-with.cjs +32 -0
- package/rules/nonblock-statement-body-position.cjs +107 -0
- package/rules/object-curly-newline.cjs +194 -0
- package/rules/object-curly-spacing.cjs +225 -0
- package/rules/object-property-newline.cjs +81 -0
- package/rules/object-shorthand.cjs +284 -0
- package/rules/one-var-declaration-per-line.cjs +75 -0
- package/rules/one-var.cjs +378 -0
- package/rules/operator-assignment.cjs +146 -0
- package/rules/operator-linebreak.cjs +150 -0
- package/rules/padded-blocks.cjs +192 -0
- package/rules/padding-line-between-statements.cjs +377 -0
- package/rules/prefer-arrow-callback.cjs +185 -0
- package/rules/prefer-const.cjs +240 -0
- package/rules/prefer-destructuring.cjs +188 -0
- package/rules/prefer-exponentiation-operator.cjs +100 -0
- package/rules/prefer-named-capture-group.cjs +111 -0
- package/rules/prefer-numeric-literals.cjs +75 -0
- package/rules/prefer-object-has-own.cjs +54 -0
- package/rules/prefer-object-spread.cjs +170 -0
- package/rules/prefer-promise-reject-errors.cjs +62 -0
- package/rules/prefer-reflect.cjs +100 -0
- package/rules/prefer-regex-literals.cjs +256 -0
- package/rules/prefer-rest-params.cjs +80 -0
- package/rules/prefer-spread.cjs +57 -0
- package/rules/prefer-template.cjs +147 -0
- package/rules/preserve-caught-error.cjs +196 -0
- package/rules/quote-props.cjs +224 -0
- package/rules/quotes.cjs +187 -0
- package/rules/radix.cjs +124 -0
- package/rules/require-atomic-updates.cjs +197 -0
- package/rules/require-await.cjs +90 -0
- package/rules/require-unicode-regexp.cjs +101 -0
- package/rules/require-yield.cjs +56 -0
- package/rules/rest-spread-spacing.cjs +99 -0
- package/rules/semi-spacing.cjs +215 -0
- package/rules/semi-style.cjs +116 -0
- package/rules/semi.cjs +239 -0
- package/rules/sort-imports.cjs +140 -0
- package/rules/sort-keys.cjs +165 -0
- package/rules/sort-vars.cjs +50 -0
- package/rules/space-before-blocks.cjs +132 -0
- package/rules/space-before-function-paren.cjs +126 -0
- package/rules/space-in-parens.cjs +175 -0
- package/rules/space-infix-ops.cjs +133 -0
- package/rules/space-unary-ops.cjs +237 -0
- package/rules/spaced-comment.cjs +233 -0
- package/rules/strict.cjs +206 -0
- package/rules/switch-colon-spacing.cjs +114 -0
- package/rules/symbol-description.cjs +49 -0
- package/rules/template-curly-spacing.cjs +112 -0
- package/rules/template-tag-spacing.cjs +82 -0
- package/rules/unicode-bom.cjs +52 -0
- package/rules/use-isnan.cjs +144 -0
- package/rules/valid-typeof.cjs +104 -0
- package/rules/vars-on-top.cjs +94 -0
- package/rules/wrap-iife.cjs +131 -0
- package/rules/wrap-regex.cjs +57 -0
- package/rules/yield-star-spacing.cjs +115 -0
- package/rules/yoda.cjs +185 -0
|
@@ -0,0 +1,1720 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@eslint-community+regexpp@4.12.2/node_modules/@eslint-community/regexpp/index.js
|
|
2
|
+
var require_regexpp = /* @__PURE__ */ require("./chunk.cjs").t(((exports) => {
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
4
|
+
var ast = /* @__PURE__ */ Object.freeze({ __proto__: null });
|
|
5
|
+
let latestEcmaVersion = 2025, largeIdStartRanges, largeIdContinueRanges;
|
|
6
|
+
function isIdStart(cp) {
|
|
7
|
+
return cp < 65 ? !1 : cp < 91 ? !0 : cp < 97 ? !1 : cp < 123 ? !0 : isLargeIdStart(cp);
|
|
8
|
+
}
|
|
9
|
+
function isIdContinue(cp) {
|
|
10
|
+
return cp < 48 ? !1 : cp < 58 ? !0 : cp < 65 ? !1 : cp < 91 || cp === 95 ? !0 : cp < 97 ? !1 : cp < 123 ? !0 : isLargeIdStart(cp) || isLargeIdContinue(cp);
|
|
11
|
+
}
|
|
12
|
+
function isLargeIdStart(cp) {
|
|
13
|
+
return isInRange(cp, largeIdStartRanges ??= initLargeIdStartRanges());
|
|
14
|
+
}
|
|
15
|
+
function isLargeIdContinue(cp) {
|
|
16
|
+
return isInRange(cp, largeIdContinueRanges ??= initLargeIdContinueRanges());
|
|
17
|
+
}
|
|
18
|
+
function initLargeIdStartRanges() {
|
|
19
|
+
return restoreRanges("4q 0 b 0 5 0 6 m 2 u 2 cp 5 b f 4 8 0 2 0 3m 4 2 1 3 3 2 0 7 0 2 2 2 0 2 j 2 2a 2 3u 9 4l 2 11 3 0 7 14 20 q 5 3 1a 16 10 1 2 2q 2 0 g 1 8 1 b 2 3 0 h 0 2 t u 2g c 0 p w a 1 5 0 6 l 5 0 a 0 4 0 o o 8 a 6 n 2 6 h 15 1n 1h 4 0 j 0 8 9 g f 5 7 3 1 3 l 2 6 2 0 4 3 4 0 h 0 e 1 2 2 f 1 b 0 9 5 5 1 3 l 2 6 2 1 2 1 2 1 w 3 2 0 k 2 h 8 2 2 2 l 2 6 2 1 2 4 4 0 j 0 g 1 o 0 c 7 3 1 3 l 2 6 2 1 2 4 4 0 v 1 2 2 g 0 i 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 b n 0 1h 7 2 2 2 m 2 f 4 0 r 2 2 1 3 1 v 0 5 7 2 2 2 m 2 9 2 4 4 0 v 2 2 1 g 1 i 8 2 2 2 14 3 0 h 0 6 2 9 2 p 5 6 h 4 n 2 8 2 0 3 6 1n 1b 2 1 d 6 1n 1 2 0 2 4 2 n 2 0 2 9 2 1 a 0 3 4 2 0 m 3 x 0 1s 7 2 z s 4 38 16 l 0 h 5 5 3 4 0 4 1 8 2 5 c d 0 i 11 2 0 6 0 3 16 2 98 2 3 3 6 2 0 2 3 3 14 2 3 3 w 2 3 3 6 2 0 2 3 3 e 2 1k 2 3 3 1u 12 f h 2d 3 5 4 h7 3 g 2 p 6 22 4 a 8 h e i f h f c 2 2 g 1f 10 0 5 0 1w 2g 8 14 2 0 6 1x b u 1e t 3 4 c 17 5 p 1j m a 1g 2b 0 2m 1a i 7 1j t e 1 b 17 r z 16 2 b z 3 a 6 16 3 2 16 3 2 5 2 1 4 0 6 5b 1t 7p 3 5 3 11 3 5 3 7 2 0 2 0 2 0 2 u 3 1g 2 6 2 0 4 2 2 6 4 3 3 5 5 c 6 2 2 6 39 0 e 0 h c 2u 0 5 0 3 9 2 0 3 5 7 0 2 0 2 0 2 f 3 3 6 4 5 0 i 14 22g 6c 7 3 4 1 d 11 2 0 6 0 3 1j 8 0 h m a 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 fb 2 q 8 8 4 3 4 5 2d 5 4 2 2h 2 3 6 16 2 2l i v 1d f e9 533 1t h3g 1w 19 3 7g 4 f b 1 l 1a h u 3 27 14 8 3 2u 3 29 l g 2 2 2 3 2 m u 1f f 1d 1r 5 4 0 2 1 c r b m q s 8 1a t 0 h 4 2 9 b 4 2 14 o 2 2 7 l m 4 0 4 1d 2 0 4 1 3 4 3 0 2 0 p 2 3 a 8 2 d 5 3 5 3 5 a 6 2 6 2 16 2 d 7 36 u 8mb d m 5 1c 6it a5 3 2x 13 6 d 4 6 0 2 9 2 c 2 4 2 0 2 1 2 1 2 2z y a2 j 1r 3 1h 15 b 39 4 2 3q 11 p 7 p c 2g 4 5 3 5 3 5 3 2 10 b 2 p 2 i 2 1 2 e 3 d z 3e 1y 1g 7g s 4 1c 1c v e t 6 11 b t 3 z 5 7 2 4 17 4d j z 5 z 5 13 9 1f d a 2 e 2 6 2 1 2 a 2 e 2 6 2 1 4 1f d 8m a l b 7 p 5 2 15 2 8 1y 5 3 0 2 17 2 1 4 0 3 m b m a u 1u i 2 1 b l b p 7 p 13 1j 7 1 1t 0 g 3 2 2 2 s 17 s 4 s 10 7 2 r s 1h b l b i e h 33 20 1k 1e e 1e e z 13 r a m 6z 15 7 1 h 5 1l s b 0 9 l 17 h 1b k s m d 1g 1m 1 3 0 e 18 x o r z u 0 3 0 9 y 4 0 d 1b f 3 m 0 2 0 10 h 2 o k 1 1s 6 2 0 2 3 2 e 2 9 8 1a 13 7 3 1 3 l 2 6 2 1 2 4 4 0 j 0 d 4 v 9 2 0 3 0 2 11 2 0 q 0 2 0 19 1g j 3 l 2 v 1b l 1 2 0 55 1a 16 3 11 1b l 0 1o 16 e 0 20 q 12 6 56 17 39 1r w 7 3 0 3 7 2 1 2 n g 0 2 0 2n 7 3 12 h 0 2 0 t 0 b 13 8 0 m 0 c 19 k 0 j 20 5k w w 8 2 10 i 0 1e t 35 6 2 1 2 11 m 0 q 5 2 1 2 v f 0 o 17 79 i g 0 2 c 2 x 3h 0 28 pl 2v 32 i 5f 219 2o g tr i 5 q 32y 6 g6 5a2 t 1cz fs 8 u i 26 i t j 1b h 3 w k 6 i c1 18 5w 1r x o 3 o 19 22 6 0 1v c 1t 1 2 0 f 4 a 5p1 16 v 2q 36 6pq 3 2 6 2 1 2 82 g 0 u 2 3 0 f 3 9 az 1s5 2y 6 c 4 8 8 9 4mf 2c 2 1y 2 1 3 0 3 1 3 3 2 b 2 0 2 6 2 1s 2 3 3 7 2 6 2 r 2 3 2 4 2 0 4 6 2 9f 3 o 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 u 2 o 2 7 1f9 u 7 5 7a 1p 43 18 b 6 h 0 8y t j 17 dh r 6d t 3 0 5s u 2 2 2 1 2 6 3 4 a 1 69 6 2 3 2 1 2 e 2 5g 1o 1v 8 0 xh 3 2 q 2 1 2 0 3 0 2 9 2 3 2 0 2 0 7 0 5 0 2 0 2 0 2 2 2 1 2 0 3 0 2 0 2 0 2 0 2 0 2 1 2 0 3 3 2 6 2 3 2 3 2 0 2 9 2 g 6 2 2 4 2 g 3et wyn x 3dp 3 4gd 3 5rk g h9 1wj f1 15v 3t6 6 6jt");
|
|
20
|
+
}
|
|
21
|
+
function initLargeIdContinueRanges() {
|
|
22
|
+
return restoreRanges("53 0 g9 33 o 0 70 4 7e 18 2 0 2 1 2 1 2 0 21 a 1d u 7 0 2u 6 3 5 3 1 2 3 3 9 o 0 v q 2k a g 9 y 8 a 0 p 3 2 8 2 2 2 4 18 2 1o 8 17 n 2 w 1j 2 2 h 2 6 b 1 3 9 i 2 1l 0 2 6 3 1 3 2 a 0 b 1 3 9 f 0 3 2 1l 0 2 4 5 1 3 2 4 0 l b 4 0 c 2 1l 0 2 7 2 2 2 2 l 1 3 9 b 5 2 2 1l 0 2 6 3 1 3 2 8 2 b 1 3 9 j 0 1o 4 4 2 2 3 a 0 f 9 h 4 1k 0 2 6 2 2 2 3 8 1 c 1 3 9 i 2 1l 0 2 6 2 2 2 3 8 1 c 1 3 9 4 0 d 3 1k 1 2 6 2 2 2 3 a 0 b 1 3 9 i 2 1z 0 5 5 2 0 2 7 7 9 3 1 1q 0 3 6 d 7 2 9 2g 0 3 8 c 6 2 9 1r 1 7 9 c 0 2 0 2 0 5 1 1e j 2 1 6 a 2 z a 0 2t j 2 9 d 3 5 2 2 2 3 6 4 3 e b 2 e jk 2 a 8 pt 3 t 2 u 1 v 1 1t v a 0 3 9 y 2 2 a 40 0 3b b 5 b b 9 3l a 1p 4 1m 9 2 s 3 a 7 9 n d 2 u 3 b l 4 1c g c 9 i 8 d 2 v c 3 9 19 d 1d j 9 9 7 9 3b 2 2 k 5 0 7 0 3 2 5j 1r el 1 1e 1 k 0 3g c 5 0 4 b 2db 2 3y 0 2p v ff 5 2y 1 2p 0 n51 9 1y 0 5 9 x 1 29 1 7l 0 4 0 5 0 o 4 5 0 2c 1 1f h b 9 7 h e a t 7 q c 19 3 1c d g 9 c 0 b 9 1c d d 0 9 1 3 9 y 2 1f 0 2 2 3 1 6 1 2 0 16 4 6 1 6l 7 2 1 3 9 fmt 0 ki f h f 4 1 p 2 5d 9 12 0 12 0 ig 0 6b 0 46 4 86 9 120 2 2 1 6 3 15 2 5 0 4m 1 fy 3 9 9 7 9 w 4 8u 1 26 5 1z a 1e 3 3f 2 1i e w a 3 1 b 3 1a a 8 0 1a 9 7 2 11 d 2 9 6 1 19 0 d 2 1d d 9 3 2 b 2b b 7 0 3 0 4e b 6 9 7 3 1k 1 2 6 3 1 3 2 a 0 b 1 3 6 4 4 1w 8 2 0 3 0 2 3 2 4 2 0 f 1 2b h a 9 5 0 2a j d 9 5y 6 3 8 s 1 2b g g 9 2a c 9 9 7 j 1m e 5 9 6r e 4m 9 1z 5 2 1 3 3 2 0 2 1 d 9 3c 6 3 6 4 0 t 9 15 6 2 3 9 0 a a 1b f 5j 7 3t 9 1i 7 2 7 h 9 1l l 2 d 3f 5 4 0 2 1 2 6 2 0 9 9 1d 4 2 1 2 4 9 9 1j 9 7e 3 a 1 2 0 1d 6 4 4 e a 44m 0 7 e 8uh r 1t3 9 2f 9 13 4 1o 6 q 9 ev 9 d2 0 2 1i 8 3 2a 0 c 1 f58 1 382 9 ef 19 3 m f3 4 4 5 9 7 3 6 v 3 45 2 13e 1d e9 1i 5 1d 9 0 f 0 n 4 2 e 11t 6 2 g 3 6 2 1 2 4 2t 0 4h 6 a 9 9x 0 1q d dv d 6t 1 2 9 6h 0 3 0 8 1 6 0 d7 6 32 6 6 9 3o7 9 gvt3 6n");
|
|
23
|
+
}
|
|
24
|
+
function isInRange(cp, ranges) {
|
|
25
|
+
let l = 0, r = ranges.length / 2 | 0, i = 0, min = 0, max = 0;
|
|
26
|
+
for (; l < r;) if (i = (l + r) / 2 | 0, min = ranges[2 * i], max = ranges[2 * i + 1], cp < min) r = i;
|
|
27
|
+
else if (cp > max) l = i + 1;
|
|
28
|
+
else return !0;
|
|
29
|
+
return !1;
|
|
30
|
+
}
|
|
31
|
+
function restoreRanges(data) {
|
|
32
|
+
let last = 0;
|
|
33
|
+
return data.split(" ").map((s) => last += parseInt(s, 36) | 0);
|
|
34
|
+
}
|
|
35
|
+
var DataSet = class {
|
|
36
|
+
constructor(raw2018, raw2019, raw2020, raw2021, raw2022, raw2023, raw2024, raw2025, raw2026) {
|
|
37
|
+
this._raw2018 = raw2018, this._raw2019 = raw2019, this._raw2020 = raw2020, this._raw2021 = raw2021, this._raw2022 = raw2022, this._raw2023 = raw2023, this._raw2024 = raw2024, this._raw2025 = raw2025, this._raw2026 = raw2026;
|
|
38
|
+
}
|
|
39
|
+
get es2018() {
|
|
40
|
+
return this._set2018 ??= new Set(this._raw2018.split(" "));
|
|
41
|
+
}
|
|
42
|
+
get es2019() {
|
|
43
|
+
return this._set2019 ??= new Set(this._raw2019.split(" "));
|
|
44
|
+
}
|
|
45
|
+
get es2020() {
|
|
46
|
+
return this._set2020 ??= new Set(this._raw2020.split(" "));
|
|
47
|
+
}
|
|
48
|
+
get es2021() {
|
|
49
|
+
return this._set2021 ??= new Set(this._raw2021.split(" "));
|
|
50
|
+
}
|
|
51
|
+
get es2022() {
|
|
52
|
+
return this._set2022 ??= new Set(this._raw2022.split(" "));
|
|
53
|
+
}
|
|
54
|
+
get es2023() {
|
|
55
|
+
return this._set2023 ??= new Set(this._raw2023.split(" "));
|
|
56
|
+
}
|
|
57
|
+
get es2024() {
|
|
58
|
+
return this._set2024 ??= new Set(this._raw2024.split(" "));
|
|
59
|
+
}
|
|
60
|
+
get es2025() {
|
|
61
|
+
return this._set2025 ??= new Set(this._raw2025.split(" "));
|
|
62
|
+
}
|
|
63
|
+
get es2026() {
|
|
64
|
+
return this._set2026 ??= new Set(this._raw2026.split(" "));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
let gcNameSet = new Set(["General_Category", "gc"]), scNameSet = new Set([
|
|
68
|
+
"Script",
|
|
69
|
+
"Script_Extensions",
|
|
70
|
+
"sc",
|
|
71
|
+
"scx"
|
|
72
|
+
]), gcValueSets = new DataSet("C Cased_Letter Cc Cf Close_Punctuation Cn Co Combining_Mark Connector_Punctuation Control Cs Currency_Symbol Dash_Punctuation Decimal_Number Enclosing_Mark Final_Punctuation Format Initial_Punctuation L LC Letter Letter_Number Line_Separator Ll Lm Lo Lowercase_Letter Lt Lu M Mark Math_Symbol Mc Me Mn Modifier_Letter Modifier_Symbol N Nd Nl No Nonspacing_Mark Number Open_Punctuation Other Other_Letter Other_Number Other_Punctuation Other_Symbol P Paragraph_Separator Pc Pd Pe Pf Pi Po Private_Use Ps Punctuation S Sc Separator Sk Sm So Space_Separator Spacing_Mark Surrogate Symbol Titlecase_Letter Unassigned Uppercase_Letter Z Zl Zp Zs cntrl digit punct", "", "", "", "", "", "", "", ""), scValueSets = new DataSet("Adlam Adlm Aghb Ahom Anatolian_Hieroglyphs Arab Arabic Armenian Armi Armn Avestan Avst Bali Balinese Bamu Bamum Bass Bassa_Vah Batak Batk Beng Bengali Bhaiksuki Bhks Bopo Bopomofo Brah Brahmi Brai Braille Bugi Buginese Buhd Buhid Cakm Canadian_Aboriginal Cans Cari Carian Caucasian_Albanian Chakma Cham Cher Cherokee Common Copt Coptic Cprt Cuneiform Cypriot Cyrillic Cyrl Deseret Deva Devanagari Dsrt Dupl Duployan Egyp Egyptian_Hieroglyphs Elba Elbasan Ethi Ethiopic Geor Georgian Glag Glagolitic Gonm Goth Gothic Gran Grantha Greek Grek Gujarati Gujr Gurmukhi Guru Han Hang Hangul Hani Hano Hanunoo Hatr Hatran Hebr Hebrew Hira Hiragana Hluw Hmng Hung Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian Ital Java Javanese Kaithi Kali Kana Kannada Katakana Kayah_Li Khar Kharoshthi Khmer Khmr Khoj Khojki Khudawadi Knda Kthi Lana Lao Laoo Latin Latn Lepc Lepcha Limb Limbu Lina Linb Linear_A Linear_B Lisu Lyci Lycian Lydi Lydian Mahajani Mahj Malayalam Mand Mandaic Mani Manichaean Marc Marchen Masaram_Gondi Meetei_Mayek Mend Mende_Kikakui Merc Mero Meroitic_Cursive Meroitic_Hieroglyphs Miao Mlym Modi Mong Mongolian Mro Mroo Mtei Mult Multani Myanmar Mymr Nabataean Narb Nbat New_Tai_Lue Newa Nko Nkoo Nshu Nushu Ogam Ogham Ol_Chiki Olck Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_South_Arabian Old_Turkic Oriya Orkh Orya Osage Osge Osma Osmanya Pahawh_Hmong Palm Palmyrene Pau_Cin_Hau Pauc Perm Phag Phags_Pa Phli Phlp Phnx Phoenician Plrd Prti Psalter_Pahlavi Qaac Qaai Rejang Rjng Runic Runr Samaritan Samr Sarb Saur Saurashtra Sgnw Sharada Shavian Shaw Shrd Sidd Siddham SignWriting Sind Sinh Sinhala Sora Sora_Sompeng Soyo Soyombo Sund Sundanese Sylo Syloti_Nagri Syrc Syriac Tagalog Tagb Tagbanwa Tai_Le Tai_Tham Tai_Viet Takr Takri Tale Talu Tamil Taml Tang Tangut Tavt Telu Telugu Tfng Tglg Thaa Thaana Thai Tibetan Tibt Tifinagh Tirh Tirhuta Ugar Ugaritic Vai Vaii Wara Warang_Citi Xpeo Xsux Yi Yiii Zanabazar_Square Zanb Zinh Zyyy", "Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo", "Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho", "Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi", "Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi", "Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz", "", "", ""), binPropertySets = new DataSet("AHex ASCII ASCII_Hex_Digit Alpha Alphabetic Any Assigned Bidi_C Bidi_Control Bidi_M Bidi_Mirrored CI CWCF CWCM CWKCF CWL CWT CWU Case_Ignorable Cased Changes_When_Casefolded Changes_When_Casemapped Changes_When_Lowercased Changes_When_NFKC_Casefolded Changes_When_Titlecased Changes_When_Uppercased DI Dash Default_Ignorable_Code_Point Dep Deprecated Dia Diacritic Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Ext Extender Gr_Base Gr_Ext Grapheme_Base Grapheme_Extend Hex Hex_Digit IDC IDS IDSB IDST IDS_Binary_Operator IDS_Trinary_Operator ID_Continue ID_Start Ideo Ideographic Join_C Join_Control LOE Logical_Order_Exception Lower Lowercase Math NChar Noncharacter_Code_Point Pat_Syn Pat_WS Pattern_Syntax Pattern_White_Space QMark Quotation_Mark RI Radical Regional_Indicator SD STerm Sentence_Terminal Soft_Dotted Term Terminal_Punctuation UIdeo Unified_Ideograph Upper Uppercase VS Variation_Selector White_Space XIDC XIDS XID_Continue XID_Start space", "Extended_Pictographic", "", "EBase EComp EMod EPres ExtPict", "", "", "", "", ""), binPropertyOfStringsSets = new DataSet("", "", "", "", "", "", "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji RGI_Emoji_Flag_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence", "", "");
|
|
73
|
+
function isValidUnicodeProperty(version, name, value) {
|
|
74
|
+
return gcNameSet.has(name) ? version >= 2018 && gcValueSets.es2018.has(value) : scNameSet.has(name) ? version >= 2018 && scValueSets.es2018.has(value) || version >= 2019 && scValueSets.es2019.has(value) || version >= 2020 && scValueSets.es2020.has(value) || version >= 2021 && scValueSets.es2021.has(value) || version >= 2022 && scValueSets.es2022.has(value) || version >= 2023 && scValueSets.es2023.has(value) : !1;
|
|
75
|
+
}
|
|
76
|
+
function isValidLoneUnicodeProperty(version, value) {
|
|
77
|
+
return version >= 2018 && binPropertySets.es2018.has(value) || version >= 2019 && binPropertySets.es2019.has(value) || version >= 2021 && binPropertySets.es2021.has(value);
|
|
78
|
+
}
|
|
79
|
+
function isValidLoneUnicodePropertyOfString(version, value) {
|
|
80
|
+
return version >= 2024 && binPropertyOfStringsSets.es2024.has(value);
|
|
81
|
+
}
|
|
82
|
+
function isLatinLetter(code) {
|
|
83
|
+
return code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
84
|
+
}
|
|
85
|
+
function isDecimalDigit(code) {
|
|
86
|
+
return code >= 48 && code <= 57;
|
|
87
|
+
}
|
|
88
|
+
function isOctalDigit(code) {
|
|
89
|
+
return code >= 48 && code <= 55;
|
|
90
|
+
}
|
|
91
|
+
function isHexDigit(code) {
|
|
92
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
|
|
93
|
+
}
|
|
94
|
+
function isLineTerminator(code) {
|
|
95
|
+
return code === 10 || code === 13 || code === 8232 || code === 8233;
|
|
96
|
+
}
|
|
97
|
+
function isValidUnicode(code) {
|
|
98
|
+
return code >= 0 && code <= 1114111;
|
|
99
|
+
}
|
|
100
|
+
function digitToInt(code) {
|
|
101
|
+
return code >= 97 && code <= 102 ? code - 97 + 10 : code >= 65 && code <= 70 ? code - 65 + 10 : code - 48;
|
|
102
|
+
}
|
|
103
|
+
function isLeadSurrogate(code) {
|
|
104
|
+
return code >= 55296 && code <= 56319;
|
|
105
|
+
}
|
|
106
|
+
function isTrailSurrogate(code) {
|
|
107
|
+
return code >= 56320 && code <= 57343;
|
|
108
|
+
}
|
|
109
|
+
function combineSurrogatePair(lead, trail) {
|
|
110
|
+
return (lead - 55296) * 1024 + (trail - 56320) + 65536;
|
|
111
|
+
}
|
|
112
|
+
var GroupSpecifiersAsES2018 = class {
|
|
113
|
+
constructor() {
|
|
114
|
+
this.groupName = /* @__PURE__ */ new Set();
|
|
115
|
+
}
|
|
116
|
+
clear() {
|
|
117
|
+
this.groupName.clear();
|
|
118
|
+
}
|
|
119
|
+
isEmpty() {
|
|
120
|
+
return !this.groupName.size;
|
|
121
|
+
}
|
|
122
|
+
hasInPattern(name) {
|
|
123
|
+
return this.groupName.has(name);
|
|
124
|
+
}
|
|
125
|
+
hasInScope(name) {
|
|
126
|
+
return this.hasInPattern(name);
|
|
127
|
+
}
|
|
128
|
+
addToScope(name) {
|
|
129
|
+
this.groupName.add(name);
|
|
130
|
+
}
|
|
131
|
+
enterDisjunction() {}
|
|
132
|
+
enterAlternative() {}
|
|
133
|
+
leaveDisjunction() {}
|
|
134
|
+
}, BranchID = class BranchID {
|
|
135
|
+
constructor(parent, base) {
|
|
136
|
+
this.parent = parent, this.base = base ?? this;
|
|
137
|
+
}
|
|
138
|
+
separatedFrom(other) {
|
|
139
|
+
return this.base === other.base && this !== other || other.parent && this.separatedFrom(other.parent) ? !0 : this.parent?.separatedFrom(other) ?? !1;
|
|
140
|
+
}
|
|
141
|
+
child() {
|
|
142
|
+
return new BranchID(this, null);
|
|
143
|
+
}
|
|
144
|
+
sibling() {
|
|
145
|
+
return new BranchID(this.parent, this.base);
|
|
146
|
+
}
|
|
147
|
+
}, GroupSpecifiersAsES2025 = class {
|
|
148
|
+
constructor() {
|
|
149
|
+
this.branchID = new BranchID(null, null), this.groupNames = /* @__PURE__ */ new Map();
|
|
150
|
+
}
|
|
151
|
+
clear() {
|
|
152
|
+
this.branchID = new BranchID(null, null), this.groupNames.clear();
|
|
153
|
+
}
|
|
154
|
+
isEmpty() {
|
|
155
|
+
return !this.groupNames.size;
|
|
156
|
+
}
|
|
157
|
+
enterDisjunction() {
|
|
158
|
+
this.branchID = this.branchID.child();
|
|
159
|
+
}
|
|
160
|
+
enterAlternative(index) {
|
|
161
|
+
index !== 0 && (this.branchID = this.branchID.sibling());
|
|
162
|
+
}
|
|
163
|
+
leaveDisjunction() {
|
|
164
|
+
this.branchID = this.branchID.parent;
|
|
165
|
+
}
|
|
166
|
+
hasInPattern(name) {
|
|
167
|
+
return this.groupNames.has(name);
|
|
168
|
+
}
|
|
169
|
+
hasInScope(name) {
|
|
170
|
+
let branches = this.groupNames.get(name);
|
|
171
|
+
if (!branches) return !1;
|
|
172
|
+
for (let branch of branches) if (!branch.separatedFrom(this.branchID)) return !0;
|
|
173
|
+
return !1;
|
|
174
|
+
}
|
|
175
|
+
addToScope(name) {
|
|
176
|
+
let branches = this.groupNames.get(name);
|
|
177
|
+
if (branches) {
|
|
178
|
+
branches.push(this.branchID);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
this.groupNames.set(name, [this.branchID]);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
let legacyImpl = {
|
|
185
|
+
at(s, end, i) {
|
|
186
|
+
return i < end ? s.charCodeAt(i) : -1;
|
|
187
|
+
},
|
|
188
|
+
width(c) {
|
|
189
|
+
return 1;
|
|
190
|
+
}
|
|
191
|
+
}, unicodeImpl = {
|
|
192
|
+
at(s, end, i) {
|
|
193
|
+
return i < end ? s.codePointAt(i) : -1;
|
|
194
|
+
},
|
|
195
|
+
width(c) {
|
|
196
|
+
return c > 65535 ? 2 : 1;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
var Reader = class {
|
|
200
|
+
constructor() {
|
|
201
|
+
this._impl = legacyImpl, this._s = "", this._i = 0, this._end = 0, this._cp1 = -1, this._w1 = 1, this._cp2 = -1, this._w2 = 1, this._cp3 = -1, this._w3 = 1, this._cp4 = -1;
|
|
202
|
+
}
|
|
203
|
+
get source() {
|
|
204
|
+
return this._s;
|
|
205
|
+
}
|
|
206
|
+
get index() {
|
|
207
|
+
return this._i;
|
|
208
|
+
}
|
|
209
|
+
get currentCodePoint() {
|
|
210
|
+
return this._cp1;
|
|
211
|
+
}
|
|
212
|
+
get nextCodePoint() {
|
|
213
|
+
return this._cp2;
|
|
214
|
+
}
|
|
215
|
+
get nextCodePoint2() {
|
|
216
|
+
return this._cp3;
|
|
217
|
+
}
|
|
218
|
+
get nextCodePoint3() {
|
|
219
|
+
return this._cp4;
|
|
220
|
+
}
|
|
221
|
+
reset(source, start, end, uFlag) {
|
|
222
|
+
this._impl = uFlag ? unicodeImpl : legacyImpl, this._s = source, this._end = end, this.rewind(start);
|
|
223
|
+
}
|
|
224
|
+
rewind(index) {
|
|
225
|
+
let impl = this._impl;
|
|
226
|
+
this._i = index, this._cp1 = impl.at(this._s, this._end, index), this._w1 = impl.width(this._cp1), this._cp2 = impl.at(this._s, this._end, index + this._w1), this._w2 = impl.width(this._cp2), this._cp3 = impl.at(this._s, this._end, index + this._w1 + this._w2), this._w3 = impl.width(this._cp3), this._cp4 = impl.at(this._s, this._end, index + this._w1 + this._w2 + this._w3);
|
|
227
|
+
}
|
|
228
|
+
advance() {
|
|
229
|
+
if (this._cp1 !== -1) {
|
|
230
|
+
let impl = this._impl;
|
|
231
|
+
this._i += this._w1, this._cp1 = this._cp2, this._w1 = this._w2, this._cp2 = this._cp3, this._w2 = impl.width(this._cp2), this._cp3 = this._cp4, this._w3 = impl.width(this._cp3), this._cp4 = impl.at(this._s, this._end, this._i + this._w1 + this._w2 + this._w3);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
eat(cp) {
|
|
235
|
+
return this._cp1 === cp ? (this.advance(), !0) : !1;
|
|
236
|
+
}
|
|
237
|
+
eat2(cp1, cp2) {
|
|
238
|
+
return this._cp1 === cp1 && this._cp2 === cp2 ? (this.advance(), this.advance(), !0) : !1;
|
|
239
|
+
}
|
|
240
|
+
eat3(cp1, cp2, cp3) {
|
|
241
|
+
return this._cp1 === cp1 && this._cp2 === cp2 && this._cp3 === cp3 ? (this.advance(), this.advance(), this.advance(), !0) : !1;
|
|
242
|
+
}
|
|
243
|
+
}, RegExpSyntaxError = class extends SyntaxError {
|
|
244
|
+
constructor(message, index) {
|
|
245
|
+
super(message), this.index = index;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
function newRegExpSyntaxError(srcCtx, flags, index, message) {
|
|
249
|
+
let source = "";
|
|
250
|
+
if (srcCtx.kind === "literal") {
|
|
251
|
+
let literal = srcCtx.source.slice(srcCtx.start, srcCtx.end);
|
|
252
|
+
literal && (source = `: ${literal}`);
|
|
253
|
+
} else srcCtx.kind === "pattern" && (source = `: /${srcCtx.source.slice(srcCtx.start, srcCtx.end)}/${`${flags.unicode ? "u" : ""}${flags.unicodeSets ? "v" : ""}`}`);
|
|
254
|
+
return new RegExpSyntaxError(`Invalid regular expression${source}: ${message}`, index);
|
|
255
|
+
}
|
|
256
|
+
let SYNTAX_CHARACTER = new Set([
|
|
257
|
+
94,
|
|
258
|
+
36,
|
|
259
|
+
92,
|
|
260
|
+
46,
|
|
261
|
+
42,
|
|
262
|
+
43,
|
|
263
|
+
63,
|
|
264
|
+
40,
|
|
265
|
+
41,
|
|
266
|
+
91,
|
|
267
|
+
93,
|
|
268
|
+
123,
|
|
269
|
+
125,
|
|
270
|
+
124
|
|
271
|
+
]), CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER = new Set([
|
|
272
|
+
38,
|
|
273
|
+
33,
|
|
274
|
+
35,
|
|
275
|
+
36,
|
|
276
|
+
37,
|
|
277
|
+
42,
|
|
278
|
+
43,
|
|
279
|
+
44,
|
|
280
|
+
46,
|
|
281
|
+
58,
|
|
282
|
+
59,
|
|
283
|
+
60,
|
|
284
|
+
61,
|
|
285
|
+
62,
|
|
286
|
+
63,
|
|
287
|
+
64,
|
|
288
|
+
94,
|
|
289
|
+
96,
|
|
290
|
+
126
|
|
291
|
+
]), CLASS_SET_SYNTAX_CHARACTER = new Set([
|
|
292
|
+
40,
|
|
293
|
+
41,
|
|
294
|
+
91,
|
|
295
|
+
93,
|
|
296
|
+
123,
|
|
297
|
+
125,
|
|
298
|
+
47,
|
|
299
|
+
45,
|
|
300
|
+
92,
|
|
301
|
+
124
|
|
302
|
+
]), CLASS_SET_RESERVED_PUNCTUATOR = new Set([
|
|
303
|
+
38,
|
|
304
|
+
45,
|
|
305
|
+
33,
|
|
306
|
+
35,
|
|
307
|
+
37,
|
|
308
|
+
44,
|
|
309
|
+
58,
|
|
310
|
+
59,
|
|
311
|
+
60,
|
|
312
|
+
61,
|
|
313
|
+
62,
|
|
314
|
+
64,
|
|
315
|
+
96,
|
|
316
|
+
126
|
|
317
|
+
]), FLAG_PROP_TO_CODEPOINT = {
|
|
318
|
+
global: 103,
|
|
319
|
+
ignoreCase: 105,
|
|
320
|
+
multiline: 109,
|
|
321
|
+
unicode: 117,
|
|
322
|
+
sticky: 121,
|
|
323
|
+
dotAll: 115,
|
|
324
|
+
hasIndices: 100,
|
|
325
|
+
unicodeSets: 118
|
|
326
|
+
}, FLAG_CODEPOINT_TO_PROP = Object.fromEntries(Object.entries(FLAG_PROP_TO_CODEPOINT).map(([k, v]) => [v, k]));
|
|
327
|
+
function isSyntaxCharacter(cp) {
|
|
328
|
+
return SYNTAX_CHARACTER.has(cp);
|
|
329
|
+
}
|
|
330
|
+
function isClassSetReservedDoublePunctuatorCharacter(cp) {
|
|
331
|
+
return CLASS_SET_RESERVED_DOUBLE_PUNCTUATOR_CHARACTER.has(cp);
|
|
332
|
+
}
|
|
333
|
+
function isClassSetSyntaxCharacter(cp) {
|
|
334
|
+
return CLASS_SET_SYNTAX_CHARACTER.has(cp);
|
|
335
|
+
}
|
|
336
|
+
function isClassSetReservedPunctuator(cp) {
|
|
337
|
+
return CLASS_SET_RESERVED_PUNCTUATOR.has(cp);
|
|
338
|
+
}
|
|
339
|
+
function isIdentifierStartChar(cp) {
|
|
340
|
+
return isIdStart(cp) || cp === 36 || cp === 95;
|
|
341
|
+
}
|
|
342
|
+
function isIdentifierPartChar(cp) {
|
|
343
|
+
return isIdContinue(cp) || cp === 36 || cp === 8204 || cp === 8205;
|
|
344
|
+
}
|
|
345
|
+
function isUnicodePropertyNameCharacter(cp) {
|
|
346
|
+
return isLatinLetter(cp) || cp === 95;
|
|
347
|
+
}
|
|
348
|
+
function isUnicodePropertyValueCharacter(cp) {
|
|
349
|
+
return isUnicodePropertyNameCharacter(cp) || isDecimalDigit(cp);
|
|
350
|
+
}
|
|
351
|
+
function isRegularExpressionModifier(ch) {
|
|
352
|
+
return ch === 105 || ch === 109 || ch === 115;
|
|
353
|
+
}
|
|
354
|
+
var RegExpValidator = class {
|
|
355
|
+
constructor(options) {
|
|
356
|
+
this._reader = new Reader(), this._unicodeMode = !1, this._unicodeSetsMode = !1, this._nFlag = !1, this._lastIntValue = 0, this._lastRange = {
|
|
357
|
+
min: 0,
|
|
358
|
+
max: Infinity
|
|
359
|
+
}, this._lastStrValue = "", this._lastAssertionIsQuantifiable = !1, this._numCapturingParens = 0, this._backreferenceNames = /* @__PURE__ */ new Set(), this._srcCtx = null, this._options = options ?? {}, this._groupSpecifiers = this.ecmaVersion >= 2025 ? new GroupSpecifiersAsES2025() : new GroupSpecifiersAsES2018();
|
|
360
|
+
}
|
|
361
|
+
validateLiteral(source, start = 0, end = source.length) {
|
|
362
|
+
if (this._srcCtx = {
|
|
363
|
+
source,
|
|
364
|
+
start,
|
|
365
|
+
end,
|
|
366
|
+
kind: "literal"
|
|
367
|
+
}, this._unicodeSetsMode = this._unicodeMode = this._nFlag = !1, this.reset(source, start, end), this.onLiteralEnter(start), this.eat(47) && this.eatRegExpBody() && this.eat(47)) {
|
|
368
|
+
let flagStart = this.index, unicode = source.includes("u", flagStart), unicodeSets = source.includes("v", flagStart);
|
|
369
|
+
this.validateFlagsInternal(source, flagStart, end), this.validatePatternInternal(source, start + 1, flagStart - 1, {
|
|
370
|
+
unicode,
|
|
371
|
+
unicodeSets
|
|
372
|
+
});
|
|
373
|
+
} else if (start >= end) this.raise("Empty");
|
|
374
|
+
else {
|
|
375
|
+
let c = String.fromCodePoint(this.currentCodePoint);
|
|
376
|
+
this.raise(`Unexpected character '${c}'`);
|
|
377
|
+
}
|
|
378
|
+
this.onLiteralLeave(start, end);
|
|
379
|
+
}
|
|
380
|
+
validateFlags(source, start = 0, end = source.length) {
|
|
381
|
+
this._srcCtx = {
|
|
382
|
+
source,
|
|
383
|
+
start,
|
|
384
|
+
end,
|
|
385
|
+
kind: "flags"
|
|
386
|
+
}, this.validateFlagsInternal(source, start, end);
|
|
387
|
+
}
|
|
388
|
+
validatePattern(source, start = 0, end = source.length, uFlagOrFlags = void 0) {
|
|
389
|
+
this._srcCtx = {
|
|
390
|
+
source,
|
|
391
|
+
start,
|
|
392
|
+
end,
|
|
393
|
+
kind: "pattern"
|
|
394
|
+
}, this.validatePatternInternal(source, start, end, uFlagOrFlags);
|
|
395
|
+
}
|
|
396
|
+
validatePatternInternal(source, start = 0, end = source.length, uFlagOrFlags = void 0) {
|
|
397
|
+
let mode = this._parseFlagsOptionToMode(uFlagOrFlags, end);
|
|
398
|
+
this._unicodeMode = mode.unicodeMode, this._nFlag = mode.nFlag, this._unicodeSetsMode = mode.unicodeSetsMode, this.reset(source, start, end), this.consumePattern(), !this._nFlag && this.ecmaVersion >= 2018 && !this._groupSpecifiers.isEmpty() && (this._nFlag = !0, this.rewind(start), this.consumePattern());
|
|
399
|
+
}
|
|
400
|
+
validateFlagsInternal(source, start, end) {
|
|
401
|
+
let flags = this.parseFlags(source, start, end);
|
|
402
|
+
this.onRegExpFlags(start, end, flags);
|
|
403
|
+
}
|
|
404
|
+
_parseFlagsOptionToMode(uFlagOrFlags, sourceEnd) {
|
|
405
|
+
let unicode = !1, unicodeSets = !1;
|
|
406
|
+
return uFlagOrFlags && this.ecmaVersion >= 2015 && (typeof uFlagOrFlags == "object" ? (unicode = !!uFlagOrFlags.unicode, this.ecmaVersion >= 2024 && (unicodeSets = !!uFlagOrFlags.unicodeSets)) : unicode = uFlagOrFlags), unicode && unicodeSets && this.raise("Invalid regular expression flags", {
|
|
407
|
+
index: sourceEnd + 1,
|
|
408
|
+
unicode,
|
|
409
|
+
unicodeSets
|
|
410
|
+
}), {
|
|
411
|
+
unicodeMode: unicode || unicodeSets,
|
|
412
|
+
nFlag: unicode && this.ecmaVersion >= 2018 || unicodeSets || !!(this._options.strict && this.ecmaVersion >= 2023),
|
|
413
|
+
unicodeSetsMode: unicodeSets
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
get strict() {
|
|
417
|
+
return !!this._options.strict || this._unicodeMode;
|
|
418
|
+
}
|
|
419
|
+
get ecmaVersion() {
|
|
420
|
+
return this._options.ecmaVersion ?? latestEcmaVersion;
|
|
421
|
+
}
|
|
422
|
+
onLiteralEnter(start) {
|
|
423
|
+
this._options.onLiteralEnter && this._options.onLiteralEnter(start);
|
|
424
|
+
}
|
|
425
|
+
onLiteralLeave(start, end) {
|
|
426
|
+
this._options.onLiteralLeave && this._options.onLiteralLeave(start, end);
|
|
427
|
+
}
|
|
428
|
+
onRegExpFlags(start, end, flags) {
|
|
429
|
+
this._options.onRegExpFlags && this._options.onRegExpFlags(start, end, flags), this._options.onFlags && this._options.onFlags(start, end, flags.global, flags.ignoreCase, flags.multiline, flags.unicode, flags.sticky, flags.dotAll, flags.hasIndices);
|
|
430
|
+
}
|
|
431
|
+
onPatternEnter(start) {
|
|
432
|
+
this._options.onPatternEnter && this._options.onPatternEnter(start);
|
|
433
|
+
}
|
|
434
|
+
onPatternLeave(start, end) {
|
|
435
|
+
this._options.onPatternLeave && this._options.onPatternLeave(start, end);
|
|
436
|
+
}
|
|
437
|
+
onDisjunctionEnter(start) {
|
|
438
|
+
this._options.onDisjunctionEnter && this._options.onDisjunctionEnter(start);
|
|
439
|
+
}
|
|
440
|
+
onDisjunctionLeave(start, end) {
|
|
441
|
+
this._options.onDisjunctionLeave && this._options.onDisjunctionLeave(start, end);
|
|
442
|
+
}
|
|
443
|
+
onAlternativeEnter(start, index) {
|
|
444
|
+
this._options.onAlternativeEnter && this._options.onAlternativeEnter(start, index);
|
|
445
|
+
}
|
|
446
|
+
onAlternativeLeave(start, end, index) {
|
|
447
|
+
this._options.onAlternativeLeave && this._options.onAlternativeLeave(start, end, index);
|
|
448
|
+
}
|
|
449
|
+
onGroupEnter(start) {
|
|
450
|
+
this._options.onGroupEnter && this._options.onGroupEnter(start);
|
|
451
|
+
}
|
|
452
|
+
onGroupLeave(start, end) {
|
|
453
|
+
this._options.onGroupLeave && this._options.onGroupLeave(start, end);
|
|
454
|
+
}
|
|
455
|
+
onModifiersEnter(start) {
|
|
456
|
+
this._options.onModifiersEnter && this._options.onModifiersEnter(start);
|
|
457
|
+
}
|
|
458
|
+
onModifiersLeave(start, end) {
|
|
459
|
+
this._options.onModifiersLeave && this._options.onModifiersLeave(start, end);
|
|
460
|
+
}
|
|
461
|
+
onAddModifiers(start, end, flags) {
|
|
462
|
+
this._options.onAddModifiers && this._options.onAddModifiers(start, end, flags);
|
|
463
|
+
}
|
|
464
|
+
onRemoveModifiers(start, end, flags) {
|
|
465
|
+
this._options.onRemoveModifiers && this._options.onRemoveModifiers(start, end, flags);
|
|
466
|
+
}
|
|
467
|
+
onCapturingGroupEnter(start, name) {
|
|
468
|
+
this._options.onCapturingGroupEnter && this._options.onCapturingGroupEnter(start, name);
|
|
469
|
+
}
|
|
470
|
+
onCapturingGroupLeave(start, end, name) {
|
|
471
|
+
this._options.onCapturingGroupLeave && this._options.onCapturingGroupLeave(start, end, name);
|
|
472
|
+
}
|
|
473
|
+
onQuantifier(start, end, min, max, greedy) {
|
|
474
|
+
this._options.onQuantifier && this._options.onQuantifier(start, end, min, max, greedy);
|
|
475
|
+
}
|
|
476
|
+
onLookaroundAssertionEnter(start, kind, negate) {
|
|
477
|
+
this._options.onLookaroundAssertionEnter && this._options.onLookaroundAssertionEnter(start, kind, negate);
|
|
478
|
+
}
|
|
479
|
+
onLookaroundAssertionLeave(start, end, kind, negate) {
|
|
480
|
+
this._options.onLookaroundAssertionLeave && this._options.onLookaroundAssertionLeave(start, end, kind, negate);
|
|
481
|
+
}
|
|
482
|
+
onEdgeAssertion(start, end, kind) {
|
|
483
|
+
this._options.onEdgeAssertion && this._options.onEdgeAssertion(start, end, kind);
|
|
484
|
+
}
|
|
485
|
+
onWordBoundaryAssertion(start, end, kind, negate) {
|
|
486
|
+
this._options.onWordBoundaryAssertion && this._options.onWordBoundaryAssertion(start, end, kind, negate);
|
|
487
|
+
}
|
|
488
|
+
onAnyCharacterSet(start, end, kind) {
|
|
489
|
+
this._options.onAnyCharacterSet && this._options.onAnyCharacterSet(start, end, kind);
|
|
490
|
+
}
|
|
491
|
+
onEscapeCharacterSet(start, end, kind, negate) {
|
|
492
|
+
this._options.onEscapeCharacterSet && this._options.onEscapeCharacterSet(start, end, kind, negate);
|
|
493
|
+
}
|
|
494
|
+
onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings) {
|
|
495
|
+
this._options.onUnicodePropertyCharacterSet && this._options.onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings);
|
|
496
|
+
}
|
|
497
|
+
onCharacter(start, end, value) {
|
|
498
|
+
this._options.onCharacter && this._options.onCharacter(start, end, value);
|
|
499
|
+
}
|
|
500
|
+
onBackreference(start, end, ref) {
|
|
501
|
+
this._options.onBackreference && this._options.onBackreference(start, end, ref);
|
|
502
|
+
}
|
|
503
|
+
onCharacterClassEnter(start, negate, unicodeSets) {
|
|
504
|
+
this._options.onCharacterClassEnter && this._options.onCharacterClassEnter(start, negate, unicodeSets);
|
|
505
|
+
}
|
|
506
|
+
onCharacterClassLeave(start, end, negate) {
|
|
507
|
+
this._options.onCharacterClassLeave && this._options.onCharacterClassLeave(start, end, negate);
|
|
508
|
+
}
|
|
509
|
+
onCharacterClassRange(start, end, min, max) {
|
|
510
|
+
this._options.onCharacterClassRange && this._options.onCharacterClassRange(start, end, min, max);
|
|
511
|
+
}
|
|
512
|
+
onClassIntersection(start, end) {
|
|
513
|
+
this._options.onClassIntersection && this._options.onClassIntersection(start, end);
|
|
514
|
+
}
|
|
515
|
+
onClassSubtraction(start, end) {
|
|
516
|
+
this._options.onClassSubtraction && this._options.onClassSubtraction(start, end);
|
|
517
|
+
}
|
|
518
|
+
onClassStringDisjunctionEnter(start) {
|
|
519
|
+
this._options.onClassStringDisjunctionEnter && this._options.onClassStringDisjunctionEnter(start);
|
|
520
|
+
}
|
|
521
|
+
onClassStringDisjunctionLeave(start, end) {
|
|
522
|
+
this._options.onClassStringDisjunctionLeave && this._options.onClassStringDisjunctionLeave(start, end);
|
|
523
|
+
}
|
|
524
|
+
onStringAlternativeEnter(start, index) {
|
|
525
|
+
this._options.onStringAlternativeEnter && this._options.onStringAlternativeEnter(start, index);
|
|
526
|
+
}
|
|
527
|
+
onStringAlternativeLeave(start, end, index) {
|
|
528
|
+
this._options.onStringAlternativeLeave && this._options.onStringAlternativeLeave(start, end, index);
|
|
529
|
+
}
|
|
530
|
+
get index() {
|
|
531
|
+
return this._reader.index;
|
|
532
|
+
}
|
|
533
|
+
get currentCodePoint() {
|
|
534
|
+
return this._reader.currentCodePoint;
|
|
535
|
+
}
|
|
536
|
+
get nextCodePoint() {
|
|
537
|
+
return this._reader.nextCodePoint;
|
|
538
|
+
}
|
|
539
|
+
get nextCodePoint2() {
|
|
540
|
+
return this._reader.nextCodePoint2;
|
|
541
|
+
}
|
|
542
|
+
get nextCodePoint3() {
|
|
543
|
+
return this._reader.nextCodePoint3;
|
|
544
|
+
}
|
|
545
|
+
reset(source, start, end) {
|
|
546
|
+
this._reader.reset(source, start, end, this._unicodeMode);
|
|
547
|
+
}
|
|
548
|
+
rewind(index) {
|
|
549
|
+
this._reader.rewind(index);
|
|
550
|
+
}
|
|
551
|
+
advance() {
|
|
552
|
+
this._reader.advance();
|
|
553
|
+
}
|
|
554
|
+
eat(cp) {
|
|
555
|
+
return this._reader.eat(cp);
|
|
556
|
+
}
|
|
557
|
+
eat2(cp1, cp2) {
|
|
558
|
+
return this._reader.eat2(cp1, cp2);
|
|
559
|
+
}
|
|
560
|
+
eat3(cp1, cp2, cp3) {
|
|
561
|
+
return this._reader.eat3(cp1, cp2, cp3);
|
|
562
|
+
}
|
|
563
|
+
raise(message, context) {
|
|
564
|
+
throw newRegExpSyntaxError(this._srcCtx, {
|
|
565
|
+
unicode: context?.unicode ?? (this._unicodeMode && !this._unicodeSetsMode),
|
|
566
|
+
unicodeSets: context?.unicodeSets ?? this._unicodeSetsMode
|
|
567
|
+
}, context?.index ?? this.index, message);
|
|
568
|
+
}
|
|
569
|
+
eatRegExpBody() {
|
|
570
|
+
let start = this.index, inClass = !1, escaped = !1;
|
|
571
|
+
for (;;) {
|
|
572
|
+
let cp = this.currentCodePoint;
|
|
573
|
+
if (cp === -1 || isLineTerminator(cp)) {
|
|
574
|
+
let kind = inClass ? "character class" : "regular expression";
|
|
575
|
+
this.raise(`Unterminated ${kind}`);
|
|
576
|
+
}
|
|
577
|
+
if (escaped) escaped = !1;
|
|
578
|
+
else if (cp === 92) escaped = !0;
|
|
579
|
+
else if (cp === 91) inClass = !0;
|
|
580
|
+
else if (cp === 93) inClass = !1;
|
|
581
|
+
else if (cp === 47 && !inClass || cp === 42 && this.index === start) break;
|
|
582
|
+
this.advance();
|
|
583
|
+
}
|
|
584
|
+
return this.index !== start;
|
|
585
|
+
}
|
|
586
|
+
consumePattern() {
|
|
587
|
+
let start = this.index;
|
|
588
|
+
this._numCapturingParens = this.countCapturingParens(), this._groupSpecifiers.clear(), this._backreferenceNames.clear(), this.onPatternEnter(start), this.consumeDisjunction();
|
|
589
|
+
let cp = this.currentCodePoint;
|
|
590
|
+
if (this.currentCodePoint !== -1) {
|
|
591
|
+
cp === 41 && this.raise("Unmatched ')'"), cp === 92 && this.raise("\\ at end of pattern"), (cp === 93 || cp === 125) && this.raise("Lone quantifier brackets");
|
|
592
|
+
let c = String.fromCodePoint(cp);
|
|
593
|
+
this.raise(`Unexpected character '${c}'`);
|
|
594
|
+
}
|
|
595
|
+
for (let name of this._backreferenceNames) this._groupSpecifiers.hasInPattern(name) || this.raise("Invalid named capture referenced");
|
|
596
|
+
this.onPatternLeave(start, this.index);
|
|
597
|
+
}
|
|
598
|
+
countCapturingParens() {
|
|
599
|
+
let start = this.index, inClass = !1, escaped = !1, count = 0, cp = 0;
|
|
600
|
+
for (; (cp = this.currentCodePoint) !== -1;) escaped ? escaped = !1 : cp === 92 ? escaped = !0 : cp === 91 ? inClass = !0 : cp === 93 ? inClass = !1 : cp === 40 && !inClass && (this.nextCodePoint !== 63 || this.nextCodePoint2 === 60 && this.nextCodePoint3 !== 61 && this.nextCodePoint3 !== 33) && (count += 1), this.advance();
|
|
601
|
+
return this.rewind(start), count;
|
|
602
|
+
}
|
|
603
|
+
consumeDisjunction() {
|
|
604
|
+
let start = this.index, i = 0;
|
|
605
|
+
this._groupSpecifiers.enterDisjunction(), this.onDisjunctionEnter(start);
|
|
606
|
+
do
|
|
607
|
+
this.consumeAlternative(i++);
|
|
608
|
+
while (this.eat(124));
|
|
609
|
+
this.consumeQuantifier(!0) && this.raise("Nothing to repeat"), this.eat(123) && this.raise("Lone quantifier brackets"), this.onDisjunctionLeave(start, this.index), this._groupSpecifiers.leaveDisjunction();
|
|
610
|
+
}
|
|
611
|
+
consumeAlternative(i) {
|
|
612
|
+
let start = this.index;
|
|
613
|
+
for (this._groupSpecifiers.enterAlternative(i), this.onAlternativeEnter(start, i); this.currentCodePoint !== -1 && this.consumeTerm(););
|
|
614
|
+
this.onAlternativeLeave(start, this.index, i);
|
|
615
|
+
}
|
|
616
|
+
consumeTerm() {
|
|
617
|
+
return this._unicodeMode || this.strict ? this.consumeAssertion() || this.consumeAtom() && this.consumeOptionalQuantifier() : this.consumeAssertion() && (!this._lastAssertionIsQuantifiable || this.consumeOptionalQuantifier()) || this.consumeExtendedAtom() && this.consumeOptionalQuantifier();
|
|
618
|
+
}
|
|
619
|
+
consumeOptionalQuantifier() {
|
|
620
|
+
return this.consumeQuantifier(), !0;
|
|
621
|
+
}
|
|
622
|
+
consumeAssertion() {
|
|
623
|
+
let start = this.index;
|
|
624
|
+
if (this._lastAssertionIsQuantifiable = !1, this.eat(94)) return this.onEdgeAssertion(start, this.index, "start"), !0;
|
|
625
|
+
if (this.eat(36)) return this.onEdgeAssertion(start, this.index, "end"), !0;
|
|
626
|
+
if (this.eat2(92, 66)) return this.onWordBoundaryAssertion(start, this.index, "word", !0), !0;
|
|
627
|
+
if (this.eat2(92, 98)) return this.onWordBoundaryAssertion(start, this.index, "word", !1), !0;
|
|
628
|
+
if (this.eat2(40, 63)) {
|
|
629
|
+
let lookbehind = this.ecmaVersion >= 2018 && this.eat(60), negate = !1;
|
|
630
|
+
if (this.eat(61) || (negate = this.eat(33))) {
|
|
631
|
+
let kind = lookbehind ? "lookbehind" : "lookahead";
|
|
632
|
+
return this.onLookaroundAssertionEnter(start, kind, negate), this.consumeDisjunction(), this.eat(41) || this.raise("Unterminated group"), this._lastAssertionIsQuantifiable = !lookbehind && !this.strict, this.onLookaroundAssertionLeave(start, this.index, kind, negate), !0;
|
|
633
|
+
}
|
|
634
|
+
this.rewind(start);
|
|
635
|
+
}
|
|
636
|
+
return !1;
|
|
637
|
+
}
|
|
638
|
+
consumeQuantifier(noConsume = !1) {
|
|
639
|
+
let start = this.index, min = 0, max = 0, greedy = !1;
|
|
640
|
+
if (this.eat(42)) min = 0, max = Infinity;
|
|
641
|
+
else if (this.eat(43)) min = 1, max = Infinity;
|
|
642
|
+
else if (this.eat(63)) min = 0, max = 1;
|
|
643
|
+
else if (this.eatBracedQuantifier(noConsume)) ({min, max} = this._lastRange);
|
|
644
|
+
else return !1;
|
|
645
|
+
return greedy = !this.eat(63), noConsume || this.onQuantifier(start, this.index, min, max, greedy), !0;
|
|
646
|
+
}
|
|
647
|
+
eatBracedQuantifier(noError) {
|
|
648
|
+
let start = this.index;
|
|
649
|
+
if (this.eat(123)) {
|
|
650
|
+
if (this.eatDecimalDigits()) {
|
|
651
|
+
let min = this._lastIntValue, max = min;
|
|
652
|
+
if (this.eat(44) && (max = this.eatDecimalDigits() ? this._lastIntValue : Infinity), this.eat(125)) return !noError && max < min && this.raise("numbers out of order in {} quantifier"), this._lastRange = {
|
|
653
|
+
min,
|
|
654
|
+
max
|
|
655
|
+
}, !0;
|
|
656
|
+
}
|
|
657
|
+
!noError && (this._unicodeMode || this.strict) && this.raise("Incomplete quantifier"), this.rewind(start);
|
|
658
|
+
}
|
|
659
|
+
return !1;
|
|
660
|
+
}
|
|
661
|
+
consumeAtom() {
|
|
662
|
+
return this.consumePatternCharacter() || this.consumeDot() || this.consumeReverseSolidusAtomEscape() || !!this.consumeCharacterClass() || this.consumeCapturingGroup() || this.consumeUncapturingGroup();
|
|
663
|
+
}
|
|
664
|
+
consumeDot() {
|
|
665
|
+
return this.eat(46) ? (this.onAnyCharacterSet(this.index - 1, this.index, "any"), !0) : !1;
|
|
666
|
+
}
|
|
667
|
+
consumeReverseSolidusAtomEscape() {
|
|
668
|
+
let start = this.index;
|
|
669
|
+
if (this.eat(92)) {
|
|
670
|
+
if (this.consumeAtomEscape()) return !0;
|
|
671
|
+
this.rewind(start);
|
|
672
|
+
}
|
|
673
|
+
return !1;
|
|
674
|
+
}
|
|
675
|
+
consumeUncapturingGroup() {
|
|
676
|
+
let start = this.index;
|
|
677
|
+
return this.eat2(40, 63) ? (this.onGroupEnter(start), this.ecmaVersion >= 2025 && this.consumeModifiers(), this.eat(58) || (this.rewind(start + 1), this.raise("Invalid group")), this.consumeDisjunction(), this.eat(41) || this.raise("Unterminated group"), this.onGroupLeave(start, this.index), !0) : !1;
|
|
678
|
+
}
|
|
679
|
+
consumeModifiers() {
|
|
680
|
+
let start = this.index, hasAddModifiers = this.eatModifiers(), addModifiersEnd = this.index, hasHyphen = this.eat(45);
|
|
681
|
+
if (!hasAddModifiers && !hasHyphen) return !1;
|
|
682
|
+
this.onModifiersEnter(start);
|
|
683
|
+
let addModifiers = this.parseModifiers(start, addModifiersEnd);
|
|
684
|
+
if (this.onAddModifiers(start, addModifiersEnd, addModifiers), hasHyphen) {
|
|
685
|
+
let modifiersStart = this.index;
|
|
686
|
+
!this.eatModifiers() && !hasAddModifiers && this.currentCodePoint === 58 && this.raise("Invalid empty flags");
|
|
687
|
+
let modifiers = this.parseModifiers(modifiersStart, this.index);
|
|
688
|
+
for (let [flagName] of Object.entries(modifiers).filter(([, enable]) => enable)) addModifiers[flagName] && this.raise(`Duplicated flag '${String.fromCodePoint(FLAG_PROP_TO_CODEPOINT[flagName])}'`);
|
|
689
|
+
this.onRemoveModifiers(modifiersStart, this.index, modifiers);
|
|
690
|
+
}
|
|
691
|
+
return this.onModifiersLeave(start, this.index), !0;
|
|
692
|
+
}
|
|
693
|
+
consumeCapturingGroup() {
|
|
694
|
+
let start = this.index;
|
|
695
|
+
if (this.eat(40)) {
|
|
696
|
+
let name = null;
|
|
697
|
+
if (this.ecmaVersion >= 2018) {
|
|
698
|
+
if (this.consumeGroupSpecifier()) name = this._lastStrValue;
|
|
699
|
+
else if (this.currentCodePoint === 63) return this.rewind(start), !1;
|
|
700
|
+
} else if (this.currentCodePoint === 63) return this.rewind(start), !1;
|
|
701
|
+
return this.onCapturingGroupEnter(start, name), this.consumeDisjunction(), this.eat(41) || this.raise("Unterminated group"), this.onCapturingGroupLeave(start, this.index, name), !0;
|
|
702
|
+
}
|
|
703
|
+
return !1;
|
|
704
|
+
}
|
|
705
|
+
consumeExtendedAtom() {
|
|
706
|
+
return this.consumeDot() || this.consumeReverseSolidusAtomEscape() || this.consumeReverseSolidusFollowedByC() || !!this.consumeCharacterClass() || this.consumeCapturingGroup() || this.consumeUncapturingGroup() || this.consumeInvalidBracedQuantifier() || this.consumeExtendedPatternCharacter();
|
|
707
|
+
}
|
|
708
|
+
consumeReverseSolidusFollowedByC() {
|
|
709
|
+
let start = this.index;
|
|
710
|
+
return this.currentCodePoint === 92 && this.nextCodePoint === 99 ? (this._lastIntValue = this.currentCodePoint, this.advance(), this.onCharacter(start, this.index, 92), !0) : !1;
|
|
711
|
+
}
|
|
712
|
+
consumeInvalidBracedQuantifier() {
|
|
713
|
+
return this.eatBracedQuantifier(!0) && this.raise("Nothing to repeat"), !1;
|
|
714
|
+
}
|
|
715
|
+
consumePatternCharacter() {
|
|
716
|
+
let start = this.index, cp = this.currentCodePoint;
|
|
717
|
+
return cp !== -1 && !isSyntaxCharacter(cp) ? (this.advance(), this.onCharacter(start, this.index, cp), !0) : !1;
|
|
718
|
+
}
|
|
719
|
+
consumeExtendedPatternCharacter() {
|
|
720
|
+
let start = this.index, cp = this.currentCodePoint;
|
|
721
|
+
return cp !== -1 && cp !== 94 && cp !== 36 && cp !== 92 && cp !== 46 && cp !== 42 && cp !== 43 && cp !== 63 && cp !== 40 && cp !== 41 && cp !== 91 && cp !== 124 ? (this.advance(), this.onCharacter(start, this.index, cp), !0) : !1;
|
|
722
|
+
}
|
|
723
|
+
consumeGroupSpecifier() {
|
|
724
|
+
let start = this.index;
|
|
725
|
+
if (this.eat(63)) {
|
|
726
|
+
if (this.eatGroupName()) {
|
|
727
|
+
if (!this._groupSpecifiers.hasInScope(this._lastStrValue)) return this._groupSpecifiers.addToScope(this._lastStrValue), !0;
|
|
728
|
+
this.raise("Duplicate capture group name");
|
|
729
|
+
}
|
|
730
|
+
this.rewind(start);
|
|
731
|
+
}
|
|
732
|
+
return !1;
|
|
733
|
+
}
|
|
734
|
+
consumeAtomEscape() {
|
|
735
|
+
return this.consumeBackreference() || this.consumeCharacterClassEscape() || this.consumeCharacterEscape() || this._nFlag && this.consumeKGroupName() ? !0 : ((this.strict || this._unicodeMode) && this.raise("Invalid escape"), !1);
|
|
736
|
+
}
|
|
737
|
+
consumeBackreference() {
|
|
738
|
+
let start = this.index;
|
|
739
|
+
if (this.eatDecimalEscape()) {
|
|
740
|
+
let n = this._lastIntValue;
|
|
741
|
+
if (n <= this._numCapturingParens) return this.onBackreference(start - 1, this.index, n), !0;
|
|
742
|
+
(this.strict || this._unicodeMode) && this.raise("Invalid escape"), this.rewind(start);
|
|
743
|
+
}
|
|
744
|
+
return !1;
|
|
745
|
+
}
|
|
746
|
+
consumeCharacterClassEscape() {
|
|
747
|
+
let start = this.index;
|
|
748
|
+
if (this.eat(100)) return this._lastIntValue = -1, this.onEscapeCharacterSet(start - 1, this.index, "digit", !1), {};
|
|
749
|
+
if (this.eat(68)) return this._lastIntValue = -1, this.onEscapeCharacterSet(start - 1, this.index, "digit", !0), {};
|
|
750
|
+
if (this.eat(115)) return this._lastIntValue = -1, this.onEscapeCharacterSet(start - 1, this.index, "space", !1), {};
|
|
751
|
+
if (this.eat(83)) return this._lastIntValue = -1, this.onEscapeCharacterSet(start - 1, this.index, "space", !0), {};
|
|
752
|
+
if (this.eat(119)) return this._lastIntValue = -1, this.onEscapeCharacterSet(start - 1, this.index, "word", !1), {};
|
|
753
|
+
if (this.eat(87)) return this._lastIntValue = -1, this.onEscapeCharacterSet(start - 1, this.index, "word", !0), {};
|
|
754
|
+
let negate = !1;
|
|
755
|
+
if (this._unicodeMode && this.ecmaVersion >= 2018 && (this.eat(112) || (negate = this.eat(80)))) {
|
|
756
|
+
this._lastIntValue = -1;
|
|
757
|
+
let result = null;
|
|
758
|
+
if (this.eat(123) && (result = this.eatUnicodePropertyValueExpression()) && this.eat(125)) return negate && result.strings && this.raise("Invalid property name"), this.onUnicodePropertyCharacterSet(start - 1, this.index, "property", result.key, result.value, negate, result.strings ?? !1), { mayContainStrings: result.strings };
|
|
759
|
+
this.raise("Invalid property name");
|
|
760
|
+
}
|
|
761
|
+
return null;
|
|
762
|
+
}
|
|
763
|
+
consumeCharacterEscape() {
|
|
764
|
+
let start = this.index;
|
|
765
|
+
return this.eatControlEscape() || this.eatCControlLetter() || this.eatZero() || this.eatHexEscapeSequence() || this.eatRegExpUnicodeEscapeSequence() || !this.strict && !this._unicodeMode && this.eatLegacyOctalEscapeSequence() || this.eatIdentityEscape() ? (this.onCharacter(start - 1, this.index, this._lastIntValue), !0) : !1;
|
|
766
|
+
}
|
|
767
|
+
consumeKGroupName() {
|
|
768
|
+
let start = this.index;
|
|
769
|
+
if (this.eat(107)) {
|
|
770
|
+
if (this.eatGroupName()) {
|
|
771
|
+
let groupName = this._lastStrValue;
|
|
772
|
+
return this._backreferenceNames.add(groupName), this.onBackreference(start - 1, this.index, groupName), !0;
|
|
773
|
+
}
|
|
774
|
+
this.raise("Invalid named reference");
|
|
775
|
+
}
|
|
776
|
+
return !1;
|
|
777
|
+
}
|
|
778
|
+
consumeCharacterClass() {
|
|
779
|
+
let start = this.index;
|
|
780
|
+
if (this.eat(91)) {
|
|
781
|
+
let negate = this.eat(94);
|
|
782
|
+
this.onCharacterClassEnter(start, negate, this._unicodeSetsMode);
|
|
783
|
+
let result = this.consumeClassContents();
|
|
784
|
+
return this.eat(93) || (this.currentCodePoint === -1 && this.raise("Unterminated character class"), this.raise("Invalid character in character class")), negate && result.mayContainStrings && this.raise("Negated character class may contain strings"), this.onCharacterClassLeave(start, this.index, negate), result;
|
|
785
|
+
}
|
|
786
|
+
return null;
|
|
787
|
+
}
|
|
788
|
+
consumeClassContents() {
|
|
789
|
+
if (this._unicodeSetsMode) return this.currentCodePoint === 93 ? {} : this.consumeClassSetExpression();
|
|
790
|
+
let strict = this.strict || this._unicodeMode;
|
|
791
|
+
for (;;) {
|
|
792
|
+
let rangeStart = this.index;
|
|
793
|
+
if (!this.consumeClassAtom()) break;
|
|
794
|
+
let min = this._lastIntValue;
|
|
795
|
+
if (!this.eat(45)) continue;
|
|
796
|
+
if (this.onCharacter(this.index - 1, this.index, 45), !this.consumeClassAtom()) break;
|
|
797
|
+
let max = this._lastIntValue;
|
|
798
|
+
if (min === -1 || max === -1) {
|
|
799
|
+
strict && this.raise("Invalid character class");
|
|
800
|
+
continue;
|
|
801
|
+
}
|
|
802
|
+
min > max && this.raise("Range out of order in character class"), this.onCharacterClassRange(rangeStart, this.index, min, max);
|
|
803
|
+
}
|
|
804
|
+
return {};
|
|
805
|
+
}
|
|
806
|
+
consumeClassAtom() {
|
|
807
|
+
let start = this.index, cp = this.currentCodePoint;
|
|
808
|
+
if (cp !== -1 && cp !== 92 && cp !== 93) return this.advance(), this._lastIntValue = cp, this.onCharacter(start, this.index, this._lastIntValue), !0;
|
|
809
|
+
if (this.eat(92)) {
|
|
810
|
+
if (this.consumeClassEscape()) return !0;
|
|
811
|
+
if (!this.strict && this.currentCodePoint === 99) return this._lastIntValue = 92, this.onCharacter(start, this.index, this._lastIntValue), !0;
|
|
812
|
+
(this.strict || this._unicodeMode) && this.raise("Invalid escape"), this.rewind(start);
|
|
813
|
+
}
|
|
814
|
+
return !1;
|
|
815
|
+
}
|
|
816
|
+
consumeClassEscape() {
|
|
817
|
+
let start = this.index;
|
|
818
|
+
if (this.eat(98)) return this._lastIntValue = 8, this.onCharacter(start - 1, this.index, this._lastIntValue), !0;
|
|
819
|
+
if (this._unicodeMode && this.eat(45)) return this._lastIntValue = 45, this.onCharacter(start - 1, this.index, this._lastIntValue), !0;
|
|
820
|
+
let cp = 0;
|
|
821
|
+
return !this.strict && !this._unicodeMode && this.currentCodePoint === 99 && (isDecimalDigit(cp = this.nextCodePoint) || cp === 95) ? (this.advance(), this.advance(), this._lastIntValue = cp % 32, this.onCharacter(start - 1, this.index, this._lastIntValue), !0) : !!this.consumeCharacterClassEscape() || this.consumeCharacterEscape();
|
|
822
|
+
}
|
|
823
|
+
consumeClassSetExpression() {
|
|
824
|
+
let start = this.index, mayContainStrings = !1, result = null;
|
|
825
|
+
if (this.consumeClassSetCharacter()) {
|
|
826
|
+
if (this.consumeClassSetRangeFromOperator(start)) return this.consumeClassUnionRight({}), {};
|
|
827
|
+
mayContainStrings = !1;
|
|
828
|
+
} else if (result = this.consumeClassSetOperand()) mayContainStrings = result.mayContainStrings;
|
|
829
|
+
else {
|
|
830
|
+
let cp = this.currentCodePoint;
|
|
831
|
+
cp === 92 && (this.advance(), this.raise("Invalid escape")), cp === this.nextCodePoint && isClassSetReservedDoublePunctuatorCharacter(cp) && this.raise("Invalid set operation in character class"), this.raise("Invalid character in character class");
|
|
832
|
+
}
|
|
833
|
+
if (this.eat2(38, 38)) {
|
|
834
|
+
for (; this.currentCodePoint !== 38 && (result = this.consumeClassSetOperand());) if (this.onClassIntersection(start, this.index), result.mayContainStrings || (mayContainStrings = !1), !this.eat2(38, 38)) return { mayContainStrings };
|
|
835
|
+
this.raise("Invalid character in character class");
|
|
836
|
+
}
|
|
837
|
+
if (this.eat2(45, 45)) {
|
|
838
|
+
for (; this.consumeClassSetOperand();) if (this.onClassSubtraction(start, this.index), !this.eat2(45, 45)) return { mayContainStrings };
|
|
839
|
+
this.raise("Invalid character in character class");
|
|
840
|
+
}
|
|
841
|
+
return this.consumeClassUnionRight({ mayContainStrings });
|
|
842
|
+
}
|
|
843
|
+
consumeClassUnionRight(leftResult) {
|
|
844
|
+
let mayContainStrings = leftResult.mayContainStrings;
|
|
845
|
+
for (;;) {
|
|
846
|
+
let start = this.index;
|
|
847
|
+
if (this.consumeClassSetCharacter()) {
|
|
848
|
+
this.consumeClassSetRangeFromOperator(start);
|
|
849
|
+
continue;
|
|
850
|
+
}
|
|
851
|
+
let result = this.consumeClassSetOperand();
|
|
852
|
+
if (result) {
|
|
853
|
+
result.mayContainStrings && (mayContainStrings = !0);
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
856
|
+
break;
|
|
857
|
+
}
|
|
858
|
+
return { mayContainStrings };
|
|
859
|
+
}
|
|
860
|
+
consumeClassSetRangeFromOperator(start) {
|
|
861
|
+
let currentStart = this.index, min = this._lastIntValue;
|
|
862
|
+
if (this.eat(45)) {
|
|
863
|
+
if (this.consumeClassSetCharacter()) {
|
|
864
|
+
let max = this._lastIntValue;
|
|
865
|
+
return (min === -1 || max === -1) && this.raise("Invalid character class"), min > max && this.raise("Range out of order in character class"), this.onCharacterClassRange(start, this.index, min, max), !0;
|
|
866
|
+
}
|
|
867
|
+
this.rewind(currentStart);
|
|
868
|
+
}
|
|
869
|
+
return !1;
|
|
870
|
+
}
|
|
871
|
+
consumeClassSetOperand() {
|
|
872
|
+
let result = null;
|
|
873
|
+
return (result = this.consumeNestedClass()) || (result = this.consumeClassStringDisjunction()) ? result : this.consumeClassSetCharacter() ? {} : null;
|
|
874
|
+
}
|
|
875
|
+
consumeNestedClass() {
|
|
876
|
+
let start = this.index;
|
|
877
|
+
if (this.eat(91)) {
|
|
878
|
+
let negate = this.eat(94);
|
|
879
|
+
this.onCharacterClassEnter(start, negate, !0);
|
|
880
|
+
let result = this.consumeClassContents();
|
|
881
|
+
return this.eat(93) || this.raise("Unterminated character class"), negate && result.mayContainStrings && this.raise("Negated character class may contain strings"), this.onCharacterClassLeave(start, this.index, negate), result;
|
|
882
|
+
}
|
|
883
|
+
if (this.eat(92)) {
|
|
884
|
+
let result = this.consumeCharacterClassEscape();
|
|
885
|
+
if (result) return result;
|
|
886
|
+
this.rewind(start);
|
|
887
|
+
}
|
|
888
|
+
return null;
|
|
889
|
+
}
|
|
890
|
+
consumeClassStringDisjunction() {
|
|
891
|
+
let start = this.index;
|
|
892
|
+
if (this.eat3(92, 113, 123)) {
|
|
893
|
+
this.onClassStringDisjunctionEnter(start);
|
|
894
|
+
let i = 0, mayContainStrings = !1;
|
|
895
|
+
do
|
|
896
|
+
this.consumeClassString(i++).mayContainStrings && (mayContainStrings = !0);
|
|
897
|
+
while (this.eat(124));
|
|
898
|
+
if (this.eat(125)) return this.onClassStringDisjunctionLeave(start, this.index), { mayContainStrings };
|
|
899
|
+
this.raise("Unterminated class string disjunction");
|
|
900
|
+
}
|
|
901
|
+
return null;
|
|
902
|
+
}
|
|
903
|
+
consumeClassString(i) {
|
|
904
|
+
let start = this.index, count = 0;
|
|
905
|
+
for (this.onStringAlternativeEnter(start, i); this.currentCodePoint !== -1 && this.consumeClassSetCharacter();) count++;
|
|
906
|
+
return this.onStringAlternativeLeave(start, this.index, i), { mayContainStrings: count !== 1 };
|
|
907
|
+
}
|
|
908
|
+
consumeClassSetCharacter() {
|
|
909
|
+
let start = this.index, cp = this.currentCodePoint;
|
|
910
|
+
if ((cp !== this.nextCodePoint || !isClassSetReservedDoublePunctuatorCharacter(cp)) && cp !== -1 && !isClassSetSyntaxCharacter(cp)) return this._lastIntValue = cp, this.advance(), this.onCharacter(start, this.index, this._lastIntValue), !0;
|
|
911
|
+
if (this.eat(92)) {
|
|
912
|
+
if (this.consumeCharacterEscape()) return !0;
|
|
913
|
+
if (isClassSetReservedPunctuator(this.currentCodePoint)) return this._lastIntValue = this.currentCodePoint, this.advance(), this.onCharacter(start, this.index, this._lastIntValue), !0;
|
|
914
|
+
if (this.eat(98)) return this._lastIntValue = 8, this.onCharacter(start, this.index, this._lastIntValue), !0;
|
|
915
|
+
this.rewind(start);
|
|
916
|
+
}
|
|
917
|
+
return !1;
|
|
918
|
+
}
|
|
919
|
+
eatGroupName() {
|
|
920
|
+
if (this.eat(60)) {
|
|
921
|
+
if (this.eatRegExpIdentifierName() && this.eat(62)) return !0;
|
|
922
|
+
this.raise("Invalid capture group name");
|
|
923
|
+
}
|
|
924
|
+
return !1;
|
|
925
|
+
}
|
|
926
|
+
eatRegExpIdentifierName() {
|
|
927
|
+
if (this.eatRegExpIdentifierStart()) {
|
|
928
|
+
for (this._lastStrValue = String.fromCodePoint(this._lastIntValue); this.eatRegExpIdentifierPart();) this._lastStrValue += String.fromCodePoint(this._lastIntValue);
|
|
929
|
+
return !0;
|
|
930
|
+
}
|
|
931
|
+
return !1;
|
|
932
|
+
}
|
|
933
|
+
eatRegExpIdentifierStart() {
|
|
934
|
+
let start = this.index, forceUFlag = !this._unicodeMode && this.ecmaVersion >= 2020, cp = this.currentCodePoint;
|
|
935
|
+
return this.advance(), cp === 92 && this.eatRegExpUnicodeEscapeSequence(forceUFlag) ? cp = this._lastIntValue : forceUFlag && isLeadSurrogate(cp) && isTrailSurrogate(this.currentCodePoint) && (cp = combineSurrogatePair(cp, this.currentCodePoint), this.advance()), isIdentifierStartChar(cp) ? (this._lastIntValue = cp, !0) : (this.index !== start && this.rewind(start), !1);
|
|
936
|
+
}
|
|
937
|
+
eatRegExpIdentifierPart() {
|
|
938
|
+
let start = this.index, forceUFlag = !this._unicodeMode && this.ecmaVersion >= 2020, cp = this.currentCodePoint;
|
|
939
|
+
return this.advance(), cp === 92 && this.eatRegExpUnicodeEscapeSequence(forceUFlag) ? cp = this._lastIntValue : forceUFlag && isLeadSurrogate(cp) && isTrailSurrogate(this.currentCodePoint) && (cp = combineSurrogatePair(cp, this.currentCodePoint), this.advance()), isIdentifierPartChar(cp) ? (this._lastIntValue = cp, !0) : (this.index !== start && this.rewind(start), !1);
|
|
940
|
+
}
|
|
941
|
+
eatCControlLetter() {
|
|
942
|
+
let start = this.index;
|
|
943
|
+
if (this.eat(99)) {
|
|
944
|
+
if (this.eatControlLetter()) return !0;
|
|
945
|
+
this.rewind(start);
|
|
946
|
+
}
|
|
947
|
+
return !1;
|
|
948
|
+
}
|
|
949
|
+
eatZero() {
|
|
950
|
+
return this.currentCodePoint === 48 && !isDecimalDigit(this.nextCodePoint) ? (this._lastIntValue = 0, this.advance(), !0) : !1;
|
|
951
|
+
}
|
|
952
|
+
eatControlEscape() {
|
|
953
|
+
return this.eat(102) ? (this._lastIntValue = 12, !0) : this.eat(110) ? (this._lastIntValue = 10, !0) : this.eat(114) ? (this._lastIntValue = 13, !0) : this.eat(116) ? (this._lastIntValue = 9, !0) : this.eat(118) ? (this._lastIntValue = 11, !0) : !1;
|
|
954
|
+
}
|
|
955
|
+
eatControlLetter() {
|
|
956
|
+
let cp = this.currentCodePoint;
|
|
957
|
+
return isLatinLetter(cp) ? (this.advance(), this._lastIntValue = cp % 32, !0) : !1;
|
|
958
|
+
}
|
|
959
|
+
eatRegExpUnicodeEscapeSequence(forceUFlag = !1) {
|
|
960
|
+
let start = this.index, uFlag = forceUFlag || this._unicodeMode;
|
|
961
|
+
if (this.eat(117)) {
|
|
962
|
+
if (uFlag && this.eatRegExpUnicodeSurrogatePairEscape() || this.eatFixedHexDigits(4) || uFlag && this.eatRegExpUnicodeCodePointEscape()) return !0;
|
|
963
|
+
(this.strict || uFlag) && this.raise("Invalid unicode escape"), this.rewind(start);
|
|
964
|
+
}
|
|
965
|
+
return !1;
|
|
966
|
+
}
|
|
967
|
+
eatRegExpUnicodeSurrogatePairEscape() {
|
|
968
|
+
let start = this.index;
|
|
969
|
+
if (this.eatFixedHexDigits(4)) {
|
|
970
|
+
let lead = this._lastIntValue;
|
|
971
|
+
if (isLeadSurrogate(lead) && this.eat(92) && this.eat(117) && this.eatFixedHexDigits(4)) {
|
|
972
|
+
let trail = this._lastIntValue;
|
|
973
|
+
if (isTrailSurrogate(trail)) return this._lastIntValue = combineSurrogatePair(lead, trail), !0;
|
|
974
|
+
}
|
|
975
|
+
this.rewind(start);
|
|
976
|
+
}
|
|
977
|
+
return !1;
|
|
978
|
+
}
|
|
979
|
+
eatRegExpUnicodeCodePointEscape() {
|
|
980
|
+
let start = this.index;
|
|
981
|
+
return this.eat(123) && this.eatHexDigits() && this.eat(125) && isValidUnicode(this._lastIntValue) ? !0 : (this.rewind(start), !1);
|
|
982
|
+
}
|
|
983
|
+
eatIdentityEscape() {
|
|
984
|
+
let cp = this.currentCodePoint;
|
|
985
|
+
return this.isValidIdentityEscape(cp) ? (this._lastIntValue = cp, this.advance(), !0) : !1;
|
|
986
|
+
}
|
|
987
|
+
isValidIdentityEscape(cp) {
|
|
988
|
+
return cp === -1 ? !1 : this._unicodeMode ? isSyntaxCharacter(cp) || cp === 47 : this.strict ? !isIdContinue(cp) : this._nFlag ? !(cp === 99 || cp === 107) : cp !== 99;
|
|
989
|
+
}
|
|
990
|
+
eatDecimalEscape() {
|
|
991
|
+
this._lastIntValue = 0;
|
|
992
|
+
let cp = this.currentCodePoint;
|
|
993
|
+
if (cp >= 49 && cp <= 57) {
|
|
994
|
+
do
|
|
995
|
+
this._lastIntValue = 10 * this._lastIntValue + (cp - 48), this.advance();
|
|
996
|
+
while ((cp = this.currentCodePoint) >= 48 && cp <= 57);
|
|
997
|
+
return !0;
|
|
998
|
+
}
|
|
999
|
+
return !1;
|
|
1000
|
+
}
|
|
1001
|
+
eatUnicodePropertyValueExpression() {
|
|
1002
|
+
let start = this.index;
|
|
1003
|
+
if (this.eatUnicodePropertyName() && this.eat(61)) {
|
|
1004
|
+
let key = this._lastStrValue;
|
|
1005
|
+
if (this.eatUnicodePropertyValue()) {
|
|
1006
|
+
let value = this._lastStrValue;
|
|
1007
|
+
if (isValidUnicodeProperty(this.ecmaVersion, key, value)) return {
|
|
1008
|
+
key,
|
|
1009
|
+
value: value || null
|
|
1010
|
+
};
|
|
1011
|
+
this.raise("Invalid property name");
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
if (this.rewind(start), this.eatLoneUnicodePropertyNameOrValue()) {
|
|
1015
|
+
let nameOrValue = this._lastStrValue;
|
|
1016
|
+
if (isValidUnicodeProperty(this.ecmaVersion, "General_Category", nameOrValue)) return {
|
|
1017
|
+
key: "General_Category",
|
|
1018
|
+
value: nameOrValue || null
|
|
1019
|
+
};
|
|
1020
|
+
if (isValidLoneUnicodeProperty(this.ecmaVersion, nameOrValue)) return {
|
|
1021
|
+
key: nameOrValue,
|
|
1022
|
+
value: null
|
|
1023
|
+
};
|
|
1024
|
+
if (this._unicodeSetsMode && isValidLoneUnicodePropertyOfString(this.ecmaVersion, nameOrValue)) return {
|
|
1025
|
+
key: nameOrValue,
|
|
1026
|
+
value: null,
|
|
1027
|
+
strings: !0
|
|
1028
|
+
};
|
|
1029
|
+
this.raise("Invalid property name");
|
|
1030
|
+
}
|
|
1031
|
+
return null;
|
|
1032
|
+
}
|
|
1033
|
+
eatUnicodePropertyName() {
|
|
1034
|
+
for (this._lastStrValue = ""; isUnicodePropertyNameCharacter(this.currentCodePoint);) this._lastStrValue += String.fromCodePoint(this.currentCodePoint), this.advance();
|
|
1035
|
+
return this._lastStrValue !== "";
|
|
1036
|
+
}
|
|
1037
|
+
eatUnicodePropertyValue() {
|
|
1038
|
+
for (this._lastStrValue = ""; isUnicodePropertyValueCharacter(this.currentCodePoint);) this._lastStrValue += String.fromCodePoint(this.currentCodePoint), this.advance();
|
|
1039
|
+
return this._lastStrValue !== "";
|
|
1040
|
+
}
|
|
1041
|
+
eatLoneUnicodePropertyNameOrValue() {
|
|
1042
|
+
return this.eatUnicodePropertyValue();
|
|
1043
|
+
}
|
|
1044
|
+
eatHexEscapeSequence() {
|
|
1045
|
+
let start = this.index;
|
|
1046
|
+
if (this.eat(120)) {
|
|
1047
|
+
if (this.eatFixedHexDigits(2)) return !0;
|
|
1048
|
+
(this._unicodeMode || this.strict) && this.raise("Invalid escape"), this.rewind(start);
|
|
1049
|
+
}
|
|
1050
|
+
return !1;
|
|
1051
|
+
}
|
|
1052
|
+
eatDecimalDigits() {
|
|
1053
|
+
let start = this.index;
|
|
1054
|
+
for (this._lastIntValue = 0; isDecimalDigit(this.currentCodePoint);) this._lastIntValue = 10 * this._lastIntValue + digitToInt(this.currentCodePoint), this.advance();
|
|
1055
|
+
return this.index !== start;
|
|
1056
|
+
}
|
|
1057
|
+
eatHexDigits() {
|
|
1058
|
+
let start = this.index;
|
|
1059
|
+
for (this._lastIntValue = 0; isHexDigit(this.currentCodePoint);) this._lastIntValue = 16 * this._lastIntValue + digitToInt(this.currentCodePoint), this.advance();
|
|
1060
|
+
return this.index !== start;
|
|
1061
|
+
}
|
|
1062
|
+
eatLegacyOctalEscapeSequence() {
|
|
1063
|
+
if (this.eatOctalDigit()) {
|
|
1064
|
+
let n1 = this._lastIntValue;
|
|
1065
|
+
if (this.eatOctalDigit()) {
|
|
1066
|
+
let n2 = this._lastIntValue;
|
|
1067
|
+
n1 <= 3 && this.eatOctalDigit() ? this._lastIntValue = n1 * 64 + n2 * 8 + this._lastIntValue : this._lastIntValue = n1 * 8 + n2;
|
|
1068
|
+
} else this._lastIntValue = n1;
|
|
1069
|
+
return !0;
|
|
1070
|
+
}
|
|
1071
|
+
return !1;
|
|
1072
|
+
}
|
|
1073
|
+
eatOctalDigit() {
|
|
1074
|
+
let cp = this.currentCodePoint;
|
|
1075
|
+
return isOctalDigit(cp) ? (this.advance(), this._lastIntValue = cp - 48, !0) : (this._lastIntValue = 0, !1);
|
|
1076
|
+
}
|
|
1077
|
+
eatFixedHexDigits(length) {
|
|
1078
|
+
let start = this.index;
|
|
1079
|
+
this._lastIntValue = 0;
|
|
1080
|
+
for (let i = 0; i < length; ++i) {
|
|
1081
|
+
let cp = this.currentCodePoint;
|
|
1082
|
+
if (!isHexDigit(cp)) return this.rewind(start), !1;
|
|
1083
|
+
this._lastIntValue = 16 * this._lastIntValue + digitToInt(cp), this.advance();
|
|
1084
|
+
}
|
|
1085
|
+
return !0;
|
|
1086
|
+
}
|
|
1087
|
+
eatModifiers() {
|
|
1088
|
+
let ate = !1;
|
|
1089
|
+
for (; isRegularExpressionModifier(this.currentCodePoint);) this.advance(), ate = !0;
|
|
1090
|
+
return ate;
|
|
1091
|
+
}
|
|
1092
|
+
parseModifiers(start, end) {
|
|
1093
|
+
let { ignoreCase, multiline, dotAll } = this.parseFlags(this._reader.source, start, end);
|
|
1094
|
+
return {
|
|
1095
|
+
ignoreCase,
|
|
1096
|
+
multiline,
|
|
1097
|
+
dotAll
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
parseFlags(source, start, end) {
|
|
1101
|
+
let flags = {
|
|
1102
|
+
global: !1,
|
|
1103
|
+
ignoreCase: !1,
|
|
1104
|
+
multiline: !1,
|
|
1105
|
+
unicode: !1,
|
|
1106
|
+
sticky: !1,
|
|
1107
|
+
dotAll: !1,
|
|
1108
|
+
hasIndices: !1,
|
|
1109
|
+
unicodeSets: !1
|
|
1110
|
+
}, validFlags = /* @__PURE__ */ new Set();
|
|
1111
|
+
validFlags.add(103), validFlags.add(105), validFlags.add(109), this.ecmaVersion >= 2015 && (validFlags.add(117), validFlags.add(121), this.ecmaVersion >= 2018 && (validFlags.add(115), this.ecmaVersion >= 2022 && (validFlags.add(100), this.ecmaVersion >= 2024 && validFlags.add(118))));
|
|
1112
|
+
for (let i = start; i < end; ++i) {
|
|
1113
|
+
let flag = source.charCodeAt(i);
|
|
1114
|
+
if (validFlags.has(flag)) {
|
|
1115
|
+
let prop = FLAG_CODEPOINT_TO_PROP[flag];
|
|
1116
|
+
flags[prop] && this.raise(`Duplicated flag '${source[i]}'`, { index: start }), flags[prop] = !0;
|
|
1117
|
+
} else this.raise(`Invalid flag '${source[i]}'`, { index: start });
|
|
1118
|
+
}
|
|
1119
|
+
return flags;
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
let DUMMY_PATTERN = {}, DUMMY_FLAGS = {}, DUMMY_CAPTURING_GROUP = {};
|
|
1123
|
+
function isClassSetOperand(node) {
|
|
1124
|
+
return node.type === "Character" || node.type === "CharacterSet" || node.type === "CharacterClass" || node.type === "ExpressionCharacterClass" || node.type === "ClassStringDisjunction";
|
|
1125
|
+
}
|
|
1126
|
+
var RegExpParserState = class {
|
|
1127
|
+
constructor(options) {
|
|
1128
|
+
this._node = DUMMY_PATTERN, this._expressionBufferMap = /* @__PURE__ */ new Map(), this._flags = DUMMY_FLAGS, this._backreferences = [], this._capturingGroups = [], this.source = "", this.strict = !!options?.strict, this.ecmaVersion = options?.ecmaVersion ?? latestEcmaVersion;
|
|
1129
|
+
}
|
|
1130
|
+
get pattern() {
|
|
1131
|
+
if (this._node.type !== "Pattern") throw Error("UnknownError");
|
|
1132
|
+
return this._node;
|
|
1133
|
+
}
|
|
1134
|
+
get flags() {
|
|
1135
|
+
if (this._flags.type !== "Flags") throw Error("UnknownError");
|
|
1136
|
+
return this._flags;
|
|
1137
|
+
}
|
|
1138
|
+
onRegExpFlags(start, end, { global, ignoreCase, multiline, unicode, sticky, dotAll, hasIndices, unicodeSets }) {
|
|
1139
|
+
this._flags = {
|
|
1140
|
+
type: "Flags",
|
|
1141
|
+
parent: null,
|
|
1142
|
+
start,
|
|
1143
|
+
end,
|
|
1144
|
+
raw: this.source.slice(start, end),
|
|
1145
|
+
global,
|
|
1146
|
+
ignoreCase,
|
|
1147
|
+
multiline,
|
|
1148
|
+
unicode,
|
|
1149
|
+
sticky,
|
|
1150
|
+
dotAll,
|
|
1151
|
+
hasIndices,
|
|
1152
|
+
unicodeSets
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
onPatternEnter(start) {
|
|
1156
|
+
this._node = {
|
|
1157
|
+
type: "Pattern",
|
|
1158
|
+
parent: null,
|
|
1159
|
+
start,
|
|
1160
|
+
end: start,
|
|
1161
|
+
raw: "",
|
|
1162
|
+
alternatives: []
|
|
1163
|
+
}, this._backreferences.length = 0, this._capturingGroups.length = 0;
|
|
1164
|
+
}
|
|
1165
|
+
onPatternLeave(start, end) {
|
|
1166
|
+
this._node.end = end, this._node.raw = this.source.slice(start, end);
|
|
1167
|
+
for (let reference of this._backreferences) {
|
|
1168
|
+
let ref = reference.ref, groups = typeof ref == "number" ? [this._capturingGroups[ref - 1]] : this._capturingGroups.filter((g) => g.name === ref);
|
|
1169
|
+
if (groups.length === 1) {
|
|
1170
|
+
let group = groups[0];
|
|
1171
|
+
reference.ambiguous = !1, reference.resolved = group;
|
|
1172
|
+
} else reference.ambiguous = !0, reference.resolved = groups;
|
|
1173
|
+
for (let group of groups) group.references.push(reference);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
onAlternativeEnter(start) {
|
|
1177
|
+
let parent = this._node;
|
|
1178
|
+
if (parent.type !== "Assertion" && parent.type !== "CapturingGroup" && parent.type !== "Group" && parent.type !== "Pattern") throw Error("UnknownError");
|
|
1179
|
+
this._node = {
|
|
1180
|
+
type: "Alternative",
|
|
1181
|
+
parent,
|
|
1182
|
+
start,
|
|
1183
|
+
end: start,
|
|
1184
|
+
raw: "",
|
|
1185
|
+
elements: []
|
|
1186
|
+
}, parent.alternatives.push(this._node);
|
|
1187
|
+
}
|
|
1188
|
+
onAlternativeLeave(start, end) {
|
|
1189
|
+
let node = this._node;
|
|
1190
|
+
if (node.type !== "Alternative") throw Error("UnknownError");
|
|
1191
|
+
node.end = end, node.raw = this.source.slice(start, end), this._node = node.parent;
|
|
1192
|
+
}
|
|
1193
|
+
onGroupEnter(start) {
|
|
1194
|
+
let parent = this._node;
|
|
1195
|
+
if (parent.type !== "Alternative") throw Error("UnknownError");
|
|
1196
|
+
this._node = {
|
|
1197
|
+
type: "Group",
|
|
1198
|
+
parent,
|
|
1199
|
+
start,
|
|
1200
|
+
end: start,
|
|
1201
|
+
raw: "",
|
|
1202
|
+
modifiers: null,
|
|
1203
|
+
alternatives: []
|
|
1204
|
+
}, parent.elements.push(this._node);
|
|
1205
|
+
}
|
|
1206
|
+
onGroupLeave(start, end) {
|
|
1207
|
+
let node = this._node;
|
|
1208
|
+
if (node.type !== "Group" || node.parent.type !== "Alternative") throw Error("UnknownError");
|
|
1209
|
+
node.end = end, node.raw = this.source.slice(start, end), this._node = node.parent;
|
|
1210
|
+
}
|
|
1211
|
+
onModifiersEnter(start) {
|
|
1212
|
+
let parent = this._node;
|
|
1213
|
+
if (parent.type !== "Group") throw Error("UnknownError");
|
|
1214
|
+
this._node = {
|
|
1215
|
+
type: "Modifiers",
|
|
1216
|
+
parent,
|
|
1217
|
+
start,
|
|
1218
|
+
end: start,
|
|
1219
|
+
raw: "",
|
|
1220
|
+
add: null,
|
|
1221
|
+
remove: null
|
|
1222
|
+
}, parent.modifiers = this._node;
|
|
1223
|
+
}
|
|
1224
|
+
onModifiersLeave(start, end) {
|
|
1225
|
+
let node = this._node;
|
|
1226
|
+
if (node.type !== "Modifiers" || node.parent.type !== "Group") throw Error("UnknownError");
|
|
1227
|
+
node.end = end, node.raw = this.source.slice(start, end), this._node = node.parent;
|
|
1228
|
+
}
|
|
1229
|
+
onAddModifiers(start, end, { ignoreCase, multiline, dotAll }) {
|
|
1230
|
+
let parent = this._node;
|
|
1231
|
+
if (parent.type !== "Modifiers") throw Error("UnknownError");
|
|
1232
|
+
parent.add = {
|
|
1233
|
+
type: "ModifierFlags",
|
|
1234
|
+
parent,
|
|
1235
|
+
start,
|
|
1236
|
+
end,
|
|
1237
|
+
raw: this.source.slice(start, end),
|
|
1238
|
+
ignoreCase,
|
|
1239
|
+
multiline,
|
|
1240
|
+
dotAll
|
|
1241
|
+
};
|
|
1242
|
+
}
|
|
1243
|
+
onRemoveModifiers(start, end, { ignoreCase, multiline, dotAll }) {
|
|
1244
|
+
let parent = this._node;
|
|
1245
|
+
if (parent.type !== "Modifiers") throw Error("UnknownError");
|
|
1246
|
+
parent.remove = {
|
|
1247
|
+
type: "ModifierFlags",
|
|
1248
|
+
parent,
|
|
1249
|
+
start,
|
|
1250
|
+
end,
|
|
1251
|
+
raw: this.source.slice(start, end),
|
|
1252
|
+
ignoreCase,
|
|
1253
|
+
multiline,
|
|
1254
|
+
dotAll
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
onCapturingGroupEnter(start, name) {
|
|
1258
|
+
let parent = this._node;
|
|
1259
|
+
if (parent.type !== "Alternative") throw Error("UnknownError");
|
|
1260
|
+
this._node = {
|
|
1261
|
+
type: "CapturingGroup",
|
|
1262
|
+
parent,
|
|
1263
|
+
start,
|
|
1264
|
+
end: start,
|
|
1265
|
+
raw: "",
|
|
1266
|
+
name,
|
|
1267
|
+
alternatives: [],
|
|
1268
|
+
references: []
|
|
1269
|
+
}, parent.elements.push(this._node), this._capturingGroups.push(this._node);
|
|
1270
|
+
}
|
|
1271
|
+
onCapturingGroupLeave(start, end) {
|
|
1272
|
+
let node = this._node;
|
|
1273
|
+
if (node.type !== "CapturingGroup" || node.parent.type !== "Alternative") throw Error("UnknownError");
|
|
1274
|
+
node.end = end, node.raw = this.source.slice(start, end), this._node = node.parent;
|
|
1275
|
+
}
|
|
1276
|
+
onQuantifier(start, end, min, max, greedy) {
|
|
1277
|
+
let parent = this._node;
|
|
1278
|
+
if (parent.type !== "Alternative") throw Error("UnknownError");
|
|
1279
|
+
let element = parent.elements.pop();
|
|
1280
|
+
if (element == null || element.type === "Quantifier" || element.type === "Assertion" && element.kind !== "lookahead") throw Error("UnknownError");
|
|
1281
|
+
let node = {
|
|
1282
|
+
type: "Quantifier",
|
|
1283
|
+
parent,
|
|
1284
|
+
start: element.start,
|
|
1285
|
+
end,
|
|
1286
|
+
raw: this.source.slice(element.start, end),
|
|
1287
|
+
min,
|
|
1288
|
+
max,
|
|
1289
|
+
greedy,
|
|
1290
|
+
element
|
|
1291
|
+
};
|
|
1292
|
+
parent.elements.push(node), element.parent = node;
|
|
1293
|
+
}
|
|
1294
|
+
onLookaroundAssertionEnter(start, kind, negate) {
|
|
1295
|
+
let parent = this._node;
|
|
1296
|
+
if (parent.type !== "Alternative") throw Error("UnknownError");
|
|
1297
|
+
let node = this._node = {
|
|
1298
|
+
type: "Assertion",
|
|
1299
|
+
parent,
|
|
1300
|
+
start,
|
|
1301
|
+
end: start,
|
|
1302
|
+
raw: "",
|
|
1303
|
+
kind,
|
|
1304
|
+
negate,
|
|
1305
|
+
alternatives: []
|
|
1306
|
+
};
|
|
1307
|
+
parent.elements.push(node);
|
|
1308
|
+
}
|
|
1309
|
+
onLookaroundAssertionLeave(start, end) {
|
|
1310
|
+
let node = this._node;
|
|
1311
|
+
if (node.type !== "Assertion" || node.parent.type !== "Alternative") throw Error("UnknownError");
|
|
1312
|
+
node.end = end, node.raw = this.source.slice(start, end), this._node = node.parent;
|
|
1313
|
+
}
|
|
1314
|
+
onEdgeAssertion(start, end, kind) {
|
|
1315
|
+
let parent = this._node;
|
|
1316
|
+
if (parent.type !== "Alternative") throw Error("UnknownError");
|
|
1317
|
+
parent.elements.push({
|
|
1318
|
+
type: "Assertion",
|
|
1319
|
+
parent,
|
|
1320
|
+
start,
|
|
1321
|
+
end,
|
|
1322
|
+
raw: this.source.slice(start, end),
|
|
1323
|
+
kind
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
onWordBoundaryAssertion(start, end, kind, negate) {
|
|
1327
|
+
let parent = this._node;
|
|
1328
|
+
if (parent.type !== "Alternative") throw Error("UnknownError");
|
|
1329
|
+
parent.elements.push({
|
|
1330
|
+
type: "Assertion",
|
|
1331
|
+
parent,
|
|
1332
|
+
start,
|
|
1333
|
+
end,
|
|
1334
|
+
raw: this.source.slice(start, end),
|
|
1335
|
+
kind,
|
|
1336
|
+
negate
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
onAnyCharacterSet(start, end, kind) {
|
|
1340
|
+
let parent = this._node;
|
|
1341
|
+
if (parent.type !== "Alternative") throw Error("UnknownError");
|
|
1342
|
+
parent.elements.push({
|
|
1343
|
+
type: "CharacterSet",
|
|
1344
|
+
parent,
|
|
1345
|
+
start,
|
|
1346
|
+
end,
|
|
1347
|
+
raw: this.source.slice(start, end),
|
|
1348
|
+
kind
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
onEscapeCharacterSet(start, end, kind, negate) {
|
|
1352
|
+
let parent = this._node;
|
|
1353
|
+
if (parent.type !== "Alternative" && parent.type !== "CharacterClass") throw Error("UnknownError");
|
|
1354
|
+
parent.elements.push({
|
|
1355
|
+
type: "CharacterSet",
|
|
1356
|
+
parent,
|
|
1357
|
+
start,
|
|
1358
|
+
end,
|
|
1359
|
+
raw: this.source.slice(start, end),
|
|
1360
|
+
kind,
|
|
1361
|
+
negate
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
onUnicodePropertyCharacterSet(start, end, kind, key, value, negate, strings) {
|
|
1365
|
+
let parent = this._node;
|
|
1366
|
+
if (parent.type !== "Alternative" && parent.type !== "CharacterClass") throw Error("UnknownError");
|
|
1367
|
+
let base = {
|
|
1368
|
+
type: "CharacterSet",
|
|
1369
|
+
parent: null,
|
|
1370
|
+
start,
|
|
1371
|
+
end,
|
|
1372
|
+
raw: this.source.slice(start, end),
|
|
1373
|
+
kind,
|
|
1374
|
+
strings: null,
|
|
1375
|
+
key
|
|
1376
|
+
};
|
|
1377
|
+
if (strings) {
|
|
1378
|
+
if (parent.type === "CharacterClass" && !parent.unicodeSets || negate || value !== null) throw Error("UnknownError");
|
|
1379
|
+
parent.elements.push(Object.assign(Object.assign({}, base), {
|
|
1380
|
+
parent,
|
|
1381
|
+
strings,
|
|
1382
|
+
value,
|
|
1383
|
+
negate
|
|
1384
|
+
}));
|
|
1385
|
+
} else parent.elements.push(Object.assign(Object.assign({}, base), {
|
|
1386
|
+
parent,
|
|
1387
|
+
strings,
|
|
1388
|
+
value,
|
|
1389
|
+
negate
|
|
1390
|
+
}));
|
|
1391
|
+
}
|
|
1392
|
+
onCharacter(start, end, value) {
|
|
1393
|
+
let parent = this._node;
|
|
1394
|
+
if (parent.type !== "Alternative" && parent.type !== "CharacterClass" && parent.type !== "StringAlternative") throw Error("UnknownError");
|
|
1395
|
+
parent.elements.push({
|
|
1396
|
+
type: "Character",
|
|
1397
|
+
parent,
|
|
1398
|
+
start,
|
|
1399
|
+
end,
|
|
1400
|
+
raw: this.source.slice(start, end),
|
|
1401
|
+
value
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
onBackreference(start, end, ref) {
|
|
1405
|
+
let parent = this._node;
|
|
1406
|
+
if (parent.type !== "Alternative") throw Error("UnknownError");
|
|
1407
|
+
let node = {
|
|
1408
|
+
type: "Backreference",
|
|
1409
|
+
parent,
|
|
1410
|
+
start,
|
|
1411
|
+
end,
|
|
1412
|
+
raw: this.source.slice(start, end),
|
|
1413
|
+
ref,
|
|
1414
|
+
ambiguous: !1,
|
|
1415
|
+
resolved: DUMMY_CAPTURING_GROUP
|
|
1416
|
+
};
|
|
1417
|
+
parent.elements.push(node), this._backreferences.push(node);
|
|
1418
|
+
}
|
|
1419
|
+
onCharacterClassEnter(start, negate, unicodeSets) {
|
|
1420
|
+
let parent = this._node, base = {
|
|
1421
|
+
type: "CharacterClass",
|
|
1422
|
+
parent,
|
|
1423
|
+
start,
|
|
1424
|
+
end: start,
|
|
1425
|
+
raw: "",
|
|
1426
|
+
unicodeSets,
|
|
1427
|
+
negate,
|
|
1428
|
+
elements: []
|
|
1429
|
+
};
|
|
1430
|
+
if (parent.type === "Alternative") {
|
|
1431
|
+
let node = Object.assign(Object.assign({}, base), { parent });
|
|
1432
|
+
this._node = node, parent.elements.push(node);
|
|
1433
|
+
} else if (parent.type === "CharacterClass" && parent.unicodeSets && unicodeSets) {
|
|
1434
|
+
let node = Object.assign(Object.assign({}, base), {
|
|
1435
|
+
parent,
|
|
1436
|
+
unicodeSets
|
|
1437
|
+
});
|
|
1438
|
+
this._node = node, parent.elements.push(node);
|
|
1439
|
+
} else throw Error("UnknownError");
|
|
1440
|
+
}
|
|
1441
|
+
onCharacterClassLeave(start, end) {
|
|
1442
|
+
let node = this._node;
|
|
1443
|
+
if (node.type !== "CharacterClass" || node.parent.type !== "Alternative" && node.parent.type !== "CharacterClass") throw Error("UnknownError");
|
|
1444
|
+
let parent = node.parent;
|
|
1445
|
+
node.end = end, node.raw = this.source.slice(start, end), this._node = parent;
|
|
1446
|
+
let expression = this._expressionBufferMap.get(node);
|
|
1447
|
+
if (!expression) return;
|
|
1448
|
+
if (node.elements.length > 0) throw Error("UnknownError");
|
|
1449
|
+
this._expressionBufferMap.delete(node);
|
|
1450
|
+
let newNode = {
|
|
1451
|
+
type: "ExpressionCharacterClass",
|
|
1452
|
+
parent,
|
|
1453
|
+
start: node.start,
|
|
1454
|
+
end: node.end,
|
|
1455
|
+
raw: node.raw,
|
|
1456
|
+
negate: node.negate,
|
|
1457
|
+
expression
|
|
1458
|
+
};
|
|
1459
|
+
if (expression.parent = newNode, node !== parent.elements.pop()) throw Error("UnknownError");
|
|
1460
|
+
parent.elements.push(newNode);
|
|
1461
|
+
}
|
|
1462
|
+
onCharacterClassRange(start, end) {
|
|
1463
|
+
let parent = this._node;
|
|
1464
|
+
if (parent.type !== "CharacterClass") throw Error("UnknownError");
|
|
1465
|
+
let elements = parent.elements, max = elements.pop();
|
|
1466
|
+
if (!max || max.type !== "Character") throw Error("UnknownError");
|
|
1467
|
+
if (!parent.unicodeSets) {
|
|
1468
|
+
let hyphen = elements.pop();
|
|
1469
|
+
if (!hyphen || hyphen.type !== "Character" || hyphen.value !== 45) throw Error("UnknownError");
|
|
1470
|
+
}
|
|
1471
|
+
let min = elements.pop();
|
|
1472
|
+
if (!min || min.type !== "Character") throw Error("UnknownError");
|
|
1473
|
+
let node = {
|
|
1474
|
+
type: "CharacterClassRange",
|
|
1475
|
+
parent,
|
|
1476
|
+
start,
|
|
1477
|
+
end,
|
|
1478
|
+
raw: this.source.slice(start, end),
|
|
1479
|
+
min,
|
|
1480
|
+
max
|
|
1481
|
+
};
|
|
1482
|
+
min.parent = node, max.parent = node, elements.push(node);
|
|
1483
|
+
}
|
|
1484
|
+
onClassIntersection(start, end) {
|
|
1485
|
+
let parent = this._node;
|
|
1486
|
+
if (parent.type !== "CharacterClass" || !parent.unicodeSets) throw Error("UnknownError");
|
|
1487
|
+
let right = parent.elements.pop(), left = this._expressionBufferMap.get(parent) ?? parent.elements.pop();
|
|
1488
|
+
if (!left || !right || left.type === "ClassSubtraction" || left.type !== "ClassIntersection" && !isClassSetOperand(left) || !isClassSetOperand(right)) throw Error("UnknownError");
|
|
1489
|
+
let node = {
|
|
1490
|
+
type: "ClassIntersection",
|
|
1491
|
+
parent,
|
|
1492
|
+
start,
|
|
1493
|
+
end,
|
|
1494
|
+
raw: this.source.slice(start, end),
|
|
1495
|
+
left,
|
|
1496
|
+
right
|
|
1497
|
+
};
|
|
1498
|
+
left.parent = node, right.parent = node, this._expressionBufferMap.set(parent, node);
|
|
1499
|
+
}
|
|
1500
|
+
onClassSubtraction(start, end) {
|
|
1501
|
+
let parent = this._node;
|
|
1502
|
+
if (parent.type !== "CharacterClass" || !parent.unicodeSets) throw Error("UnknownError");
|
|
1503
|
+
let right = parent.elements.pop(), left = this._expressionBufferMap.get(parent) ?? parent.elements.pop();
|
|
1504
|
+
if (!left || !right || left.type === "ClassIntersection" || left.type !== "ClassSubtraction" && !isClassSetOperand(left) || !isClassSetOperand(right)) throw Error("UnknownError");
|
|
1505
|
+
let node = {
|
|
1506
|
+
type: "ClassSubtraction",
|
|
1507
|
+
parent,
|
|
1508
|
+
start,
|
|
1509
|
+
end,
|
|
1510
|
+
raw: this.source.slice(start, end),
|
|
1511
|
+
left,
|
|
1512
|
+
right
|
|
1513
|
+
};
|
|
1514
|
+
left.parent = node, right.parent = node, this._expressionBufferMap.set(parent, node);
|
|
1515
|
+
}
|
|
1516
|
+
onClassStringDisjunctionEnter(start) {
|
|
1517
|
+
let parent = this._node;
|
|
1518
|
+
if (parent.type !== "CharacterClass" || !parent.unicodeSets) throw Error("UnknownError");
|
|
1519
|
+
this._node = {
|
|
1520
|
+
type: "ClassStringDisjunction",
|
|
1521
|
+
parent,
|
|
1522
|
+
start,
|
|
1523
|
+
end: start,
|
|
1524
|
+
raw: "",
|
|
1525
|
+
alternatives: []
|
|
1526
|
+
}, parent.elements.push(this._node);
|
|
1527
|
+
}
|
|
1528
|
+
onClassStringDisjunctionLeave(start, end) {
|
|
1529
|
+
let node = this._node;
|
|
1530
|
+
if (node.type !== "ClassStringDisjunction" || node.parent.type !== "CharacterClass") throw Error("UnknownError");
|
|
1531
|
+
node.end = end, node.raw = this.source.slice(start, end), this._node = node.parent;
|
|
1532
|
+
}
|
|
1533
|
+
onStringAlternativeEnter(start) {
|
|
1534
|
+
let parent = this._node;
|
|
1535
|
+
if (parent.type !== "ClassStringDisjunction") throw Error("UnknownError");
|
|
1536
|
+
this._node = {
|
|
1537
|
+
type: "StringAlternative",
|
|
1538
|
+
parent,
|
|
1539
|
+
start,
|
|
1540
|
+
end: start,
|
|
1541
|
+
raw: "",
|
|
1542
|
+
elements: []
|
|
1543
|
+
}, parent.alternatives.push(this._node);
|
|
1544
|
+
}
|
|
1545
|
+
onStringAlternativeLeave(start, end) {
|
|
1546
|
+
let node = this._node;
|
|
1547
|
+
if (node.type !== "StringAlternative") throw Error("UnknownError");
|
|
1548
|
+
node.end = end, node.raw = this.source.slice(start, end), this._node = node.parent;
|
|
1549
|
+
}
|
|
1550
|
+
}, RegExpParser = class {
|
|
1551
|
+
constructor(options) {
|
|
1552
|
+
this._state = new RegExpParserState(options), this._validator = new RegExpValidator(this._state);
|
|
1553
|
+
}
|
|
1554
|
+
parseLiteral(source, start = 0, end = source.length) {
|
|
1555
|
+
this._state.source = source, this._validator.validateLiteral(source, start, end);
|
|
1556
|
+
let pattern = this._state.pattern, flags = this._state.flags, literal = {
|
|
1557
|
+
type: "RegExpLiteral",
|
|
1558
|
+
parent: null,
|
|
1559
|
+
start,
|
|
1560
|
+
end,
|
|
1561
|
+
raw: source,
|
|
1562
|
+
pattern,
|
|
1563
|
+
flags
|
|
1564
|
+
};
|
|
1565
|
+
return pattern.parent = literal, flags.parent = literal, literal;
|
|
1566
|
+
}
|
|
1567
|
+
parseFlags(source, start = 0, end = source.length) {
|
|
1568
|
+
return this._state.source = source, this._validator.validateFlags(source, start, end), this._state.flags;
|
|
1569
|
+
}
|
|
1570
|
+
parsePattern(source, start = 0, end = source.length, uFlagOrFlags = void 0) {
|
|
1571
|
+
return this._state.source = source, this._validator.validatePattern(source, start, end, uFlagOrFlags), this._state.pattern;
|
|
1572
|
+
}
|
|
1573
|
+
}, RegExpVisitor = class {
|
|
1574
|
+
constructor(handlers) {
|
|
1575
|
+
this._handlers = handlers;
|
|
1576
|
+
}
|
|
1577
|
+
visit(node) {
|
|
1578
|
+
switch (node.type) {
|
|
1579
|
+
case "Alternative":
|
|
1580
|
+
this.visitAlternative(node);
|
|
1581
|
+
break;
|
|
1582
|
+
case "Assertion":
|
|
1583
|
+
this.visitAssertion(node);
|
|
1584
|
+
break;
|
|
1585
|
+
case "Backreference":
|
|
1586
|
+
this.visitBackreference(node);
|
|
1587
|
+
break;
|
|
1588
|
+
case "CapturingGroup":
|
|
1589
|
+
this.visitCapturingGroup(node);
|
|
1590
|
+
break;
|
|
1591
|
+
case "Character":
|
|
1592
|
+
this.visitCharacter(node);
|
|
1593
|
+
break;
|
|
1594
|
+
case "CharacterClass":
|
|
1595
|
+
this.visitCharacterClass(node);
|
|
1596
|
+
break;
|
|
1597
|
+
case "CharacterClassRange":
|
|
1598
|
+
this.visitCharacterClassRange(node);
|
|
1599
|
+
break;
|
|
1600
|
+
case "CharacterSet":
|
|
1601
|
+
this.visitCharacterSet(node);
|
|
1602
|
+
break;
|
|
1603
|
+
case "ClassIntersection":
|
|
1604
|
+
this.visitClassIntersection(node);
|
|
1605
|
+
break;
|
|
1606
|
+
case "ClassStringDisjunction":
|
|
1607
|
+
this.visitClassStringDisjunction(node);
|
|
1608
|
+
break;
|
|
1609
|
+
case "ClassSubtraction":
|
|
1610
|
+
this.visitClassSubtraction(node);
|
|
1611
|
+
break;
|
|
1612
|
+
case "ExpressionCharacterClass":
|
|
1613
|
+
this.visitExpressionCharacterClass(node);
|
|
1614
|
+
break;
|
|
1615
|
+
case "Flags":
|
|
1616
|
+
this.visitFlags(node);
|
|
1617
|
+
break;
|
|
1618
|
+
case "Group":
|
|
1619
|
+
this.visitGroup(node);
|
|
1620
|
+
break;
|
|
1621
|
+
case "Modifiers":
|
|
1622
|
+
this.visitModifiers(node);
|
|
1623
|
+
break;
|
|
1624
|
+
case "ModifierFlags":
|
|
1625
|
+
this.visitModifierFlags(node);
|
|
1626
|
+
break;
|
|
1627
|
+
case "Pattern":
|
|
1628
|
+
this.visitPattern(node);
|
|
1629
|
+
break;
|
|
1630
|
+
case "Quantifier":
|
|
1631
|
+
this.visitQuantifier(node);
|
|
1632
|
+
break;
|
|
1633
|
+
case "RegExpLiteral":
|
|
1634
|
+
this.visitRegExpLiteral(node);
|
|
1635
|
+
break;
|
|
1636
|
+
case "StringAlternative":
|
|
1637
|
+
this.visitStringAlternative(node);
|
|
1638
|
+
break;
|
|
1639
|
+
default: throw Error(`Unknown type: ${node.type}`);
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
visitAlternative(node) {
|
|
1643
|
+
this._handlers.onAlternativeEnter && this._handlers.onAlternativeEnter(node), node.elements.forEach(this.visit, this), this._handlers.onAlternativeLeave && this._handlers.onAlternativeLeave(node);
|
|
1644
|
+
}
|
|
1645
|
+
visitAssertion(node) {
|
|
1646
|
+
this._handlers.onAssertionEnter && this._handlers.onAssertionEnter(node), (node.kind === "lookahead" || node.kind === "lookbehind") && node.alternatives.forEach(this.visit, this), this._handlers.onAssertionLeave && this._handlers.onAssertionLeave(node);
|
|
1647
|
+
}
|
|
1648
|
+
visitBackreference(node) {
|
|
1649
|
+
this._handlers.onBackreferenceEnter && this._handlers.onBackreferenceEnter(node), this._handlers.onBackreferenceLeave && this._handlers.onBackreferenceLeave(node);
|
|
1650
|
+
}
|
|
1651
|
+
visitCapturingGroup(node) {
|
|
1652
|
+
this._handlers.onCapturingGroupEnter && this._handlers.onCapturingGroupEnter(node), node.alternatives.forEach(this.visit, this), this._handlers.onCapturingGroupLeave && this._handlers.onCapturingGroupLeave(node);
|
|
1653
|
+
}
|
|
1654
|
+
visitCharacter(node) {
|
|
1655
|
+
this._handlers.onCharacterEnter && this._handlers.onCharacterEnter(node), this._handlers.onCharacterLeave && this._handlers.onCharacterLeave(node);
|
|
1656
|
+
}
|
|
1657
|
+
visitCharacterClass(node) {
|
|
1658
|
+
this._handlers.onCharacterClassEnter && this._handlers.onCharacterClassEnter(node), node.elements.forEach(this.visit, this), this._handlers.onCharacterClassLeave && this._handlers.onCharacterClassLeave(node);
|
|
1659
|
+
}
|
|
1660
|
+
visitCharacterClassRange(node) {
|
|
1661
|
+
this._handlers.onCharacterClassRangeEnter && this._handlers.onCharacterClassRangeEnter(node), this.visitCharacter(node.min), this.visitCharacter(node.max), this._handlers.onCharacterClassRangeLeave && this._handlers.onCharacterClassRangeLeave(node);
|
|
1662
|
+
}
|
|
1663
|
+
visitCharacterSet(node) {
|
|
1664
|
+
this._handlers.onCharacterSetEnter && this._handlers.onCharacterSetEnter(node), this._handlers.onCharacterSetLeave && this._handlers.onCharacterSetLeave(node);
|
|
1665
|
+
}
|
|
1666
|
+
visitClassIntersection(node) {
|
|
1667
|
+
this._handlers.onClassIntersectionEnter && this._handlers.onClassIntersectionEnter(node), this.visit(node.left), this.visit(node.right), this._handlers.onClassIntersectionLeave && this._handlers.onClassIntersectionLeave(node);
|
|
1668
|
+
}
|
|
1669
|
+
visitClassStringDisjunction(node) {
|
|
1670
|
+
this._handlers.onClassStringDisjunctionEnter && this._handlers.onClassStringDisjunctionEnter(node), node.alternatives.forEach(this.visit, this), this._handlers.onClassStringDisjunctionLeave && this._handlers.onClassStringDisjunctionLeave(node);
|
|
1671
|
+
}
|
|
1672
|
+
visitClassSubtraction(node) {
|
|
1673
|
+
this._handlers.onClassSubtractionEnter && this._handlers.onClassSubtractionEnter(node), this.visit(node.left), this.visit(node.right), this._handlers.onClassSubtractionLeave && this._handlers.onClassSubtractionLeave(node);
|
|
1674
|
+
}
|
|
1675
|
+
visitExpressionCharacterClass(node) {
|
|
1676
|
+
this._handlers.onExpressionCharacterClassEnter && this._handlers.onExpressionCharacterClassEnter(node), this.visit(node.expression), this._handlers.onExpressionCharacterClassLeave && this._handlers.onExpressionCharacterClassLeave(node);
|
|
1677
|
+
}
|
|
1678
|
+
visitFlags(node) {
|
|
1679
|
+
this._handlers.onFlagsEnter && this._handlers.onFlagsEnter(node), this._handlers.onFlagsLeave && this._handlers.onFlagsLeave(node);
|
|
1680
|
+
}
|
|
1681
|
+
visitGroup(node) {
|
|
1682
|
+
this._handlers.onGroupEnter && this._handlers.onGroupEnter(node), node.modifiers && this.visit(node.modifiers), node.alternatives.forEach(this.visit, this), this._handlers.onGroupLeave && this._handlers.onGroupLeave(node);
|
|
1683
|
+
}
|
|
1684
|
+
visitModifiers(node) {
|
|
1685
|
+
this._handlers.onModifiersEnter && this._handlers.onModifiersEnter(node), node.add && this.visit(node.add), node.remove && this.visit(node.remove), this._handlers.onModifiersLeave && this._handlers.onModifiersLeave(node);
|
|
1686
|
+
}
|
|
1687
|
+
visitModifierFlags(node) {
|
|
1688
|
+
this._handlers.onModifierFlagsEnter && this._handlers.onModifierFlagsEnter(node), this._handlers.onModifierFlagsLeave && this._handlers.onModifierFlagsLeave(node);
|
|
1689
|
+
}
|
|
1690
|
+
visitPattern(node) {
|
|
1691
|
+
this._handlers.onPatternEnter && this._handlers.onPatternEnter(node), node.alternatives.forEach(this.visit, this), this._handlers.onPatternLeave && this._handlers.onPatternLeave(node);
|
|
1692
|
+
}
|
|
1693
|
+
visitQuantifier(node) {
|
|
1694
|
+
this._handlers.onQuantifierEnter && this._handlers.onQuantifierEnter(node), this.visit(node.element), this._handlers.onQuantifierLeave && this._handlers.onQuantifierLeave(node);
|
|
1695
|
+
}
|
|
1696
|
+
visitRegExpLiteral(node) {
|
|
1697
|
+
this._handlers.onRegExpLiteralEnter && this._handlers.onRegExpLiteralEnter(node), this.visitPattern(node.pattern), this.visitFlags(node.flags), this._handlers.onRegExpLiteralLeave && this._handlers.onRegExpLiteralLeave(node);
|
|
1698
|
+
}
|
|
1699
|
+
visitStringAlternative(node) {
|
|
1700
|
+
this._handlers.onStringAlternativeEnter && this._handlers.onStringAlternativeEnter(node), node.elements.forEach(this.visit, this), this._handlers.onStringAlternativeLeave && this._handlers.onStringAlternativeLeave(node);
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1703
|
+
function parseRegExpLiteral(source, options) {
|
|
1704
|
+
return new RegExpParser(options).parseLiteral(String(source));
|
|
1705
|
+
}
|
|
1706
|
+
function validateRegExpLiteral(source, options) {
|
|
1707
|
+
new RegExpValidator(options).validateLiteral(source);
|
|
1708
|
+
}
|
|
1709
|
+
function visitRegExpAST(node, handlers) {
|
|
1710
|
+
new RegExpVisitor(handlers).visit(node);
|
|
1711
|
+
}
|
|
1712
|
+
exports.AST = ast, exports.RegExpParser = RegExpParser, exports.RegExpSyntaxError = RegExpSyntaxError, exports.RegExpValidator = RegExpValidator, exports.parseRegExpLiteral = parseRegExpLiteral, exports.validateRegExpLiteral = validateRegExpLiteral, exports.visitRegExpAST = visitRegExpAST;
|
|
1713
|
+
}));
|
|
1714
|
+
//#endregion
|
|
1715
|
+
Object.defineProperty(exports, "t", {
|
|
1716
|
+
enumerable: !0,
|
|
1717
|
+
get: function() {
|
|
1718
|
+
return require_regexpp;
|
|
1719
|
+
}
|
|
1720
|
+
});
|