tsc-ts 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -1
- package/dist/api/compiler/ast-utilities.d.ts +82 -0
- package/dist/api/compiler/ast-utilities.js +462 -0
- package/dist/api/compiler/ast.d.ts +2350 -0
- package/dist/api/compiler/ast.js +11206 -0
- package/dist/api/compiler/astnav.d.ts +37 -0
- package/dist/api/compiler/astnav.js +767 -0
- package/dist/api/compiler/binder-utilities.d.ts +182 -0
- package/dist/api/compiler/binder-utilities.js +1240 -0
- package/dist/api/compiler/binder.d.ts +33 -0
- package/dist/api/compiler/binder.js +2358 -0
- package/dist/api/compiler/character-codes.d.ts +161 -0
- package/dist/api/compiler/character-codes.js +160 -0
- package/dist/api/compiler/checker-calls.d.ts +46 -0
- package/dist/api/compiler/checker-calls.js +1640 -0
- package/dist/api/compiler/checker-classes.d.ts +30 -0
- package/dist/api/compiler/checker-classes.js +582 -0
- package/dist/api/compiler/checker-contextual.d.ts +77 -0
- package/dist/api/compiler/checker-contextual.js +1136 -0
- package/dist/api/compiler/checker-declaration-order.d.ts +12 -0
- package/dist/api/compiler/checker-declaration-order.js +356 -0
- package/dist/api/compiler/checker-declarations.d.ts +33 -0
- package/dist/api/compiler/checker-declarations.js +888 -0
- package/dist/api/compiler/checker-declared-types.d.ts +48 -0
- package/dist/api/compiler/checker-declared-types.js +787 -0
- package/dist/api/compiler/checker-decorators.d.ts +26 -0
- package/dist/api/compiler/checker-decorators.js +562 -0
- package/dist/api/compiler/checker-deprecation.d.ts +33 -0
- package/dist/api/compiler/checker-deprecation.js +315 -0
- package/dist/api/compiler/checker-destructuring.d.ts +34 -0
- package/dist/api/compiler/checker-destructuring.js +584 -0
- package/dist/api/compiler/checker-elaboration.d.ts +15 -0
- package/dist/api/compiler/checker-elaboration.js +290 -0
- package/dist/api/compiler/checker-emit-helpers.d.ts +58 -0
- package/dist/api/compiler/checker-emit-helpers.js +154 -0
- package/dist/api/compiler/checker-emit-resolver.d.ts +75 -0
- package/dist/api/compiler/checker-emit-resolver.js +579 -0
- package/dist/api/compiler/checker-evaluator.d.ts +27 -0
- package/dist/api/compiler/checker-evaluator.js +188 -0
- package/dist/api/compiler/checker-expressions.d.ts +67 -0
- package/dist/api/compiler/checker-expressions.js +1351 -0
- package/dist/api/compiler/checker-features.d.ts +6 -0
- package/dist/api/compiler/checker-features.js +354 -0
- package/dist/api/compiler/checker-flow.d.ts +86 -0
- package/dist/api/compiler/checker-flow.js +169 -0
- package/dist/api/compiler/checker-functions.d.ts +43 -0
- package/dist/api/compiler/checker-functions.js +1002 -0
- package/dist/api/compiler/checker-generated-code.d.ts +25 -0
- package/dist/api/compiler/checker-generated-code.js +168 -0
- package/dist/api/compiler/checker-globals.d.ts +14 -0
- package/dist/api/compiler/checker-globals.js +37 -0
- package/dist/api/compiler/checker-grammar.d.ts +35 -0
- package/dist/api/compiler/checker-grammar.js +2573 -0
- package/dist/api/compiler/checker-heritage.d.ts +28 -0
- package/dist/api/compiler/checker-heritage.js +900 -0
- package/dist/api/compiler/checker-inference.d.ts +179 -0
- package/dist/api/compiler/checker-inference.js +2105 -0
- package/dist/api/compiler/checker-iteration.d.ts +115 -0
- package/dist/api/compiler/checker-iteration.js +857 -0
- package/dist/api/compiler/checker-javascript.d.ts +42 -0
- package/dist/api/compiler/checker-javascript.js +441 -0
- package/dist/api/compiler/checker-jsdoc.d.ts +30 -0
- package/dist/api/compiler/checker-jsdoc.js +320 -0
- package/dist/api/compiler/checker-jsx.d.ts +94 -0
- package/dist/api/compiler/checker-jsx.js +1433 -0
- package/dist/api/compiler/checker-literals.d.ts +6 -0
- package/dist/api/compiler/checker-literals.js +43 -0
- package/dist/api/compiler/checker-members.d.ts +198 -0
- package/dist/api/compiler/checker-members.js +2126 -0
- package/dist/api/compiler/checker-modules.d.ts +85 -0
- package/dist/api/compiler/checker-modules.js +2141 -0
- package/dist/api/compiler/checker-narrowing.d.ts +120 -0
- package/dist/api/compiler/checker-narrowing.js +2797 -0
- package/dist/api/compiler/checker-object-literals.d.ts +14 -0
- package/dist/api/compiler/checker-object-literals.js +479 -0
- package/dist/api/compiler/checker-operators.d.ts +33 -0
- package/dist/api/compiler/checker-operators.js +1040 -0
- package/dist/api/compiler/checker-overloads.d.ts +7 -0
- package/dist/api/compiler/checker-overloads.js +270 -0
- package/dist/api/compiler/checker-property-access.d.ts +34 -0
- package/dist/api/compiler/checker-property-access.js +672 -0
- package/dist/api/compiler/checker-services.d.ts +49 -0
- package/dist/api/compiler/checker-services.js +995 -0
- package/dist/api/compiler/checker-signatures.d.ts +55 -0
- package/dist/api/compiler/checker-signatures.js +788 -0
- package/dist/api/compiler/checker-source-file.d.ts +27 -0
- package/dist/api/compiler/checker-source-file.js +619 -0
- package/dist/api/compiler/checker-statements.d.ts +18 -0
- package/dist/api/compiler/checker-statements.js +226 -0
- package/dist/api/compiler/checker-super.d.ts +13 -0
- package/dist/api/compiler/checker-super.js +241 -0
- package/dist/api/compiler/checker-symbol-types.d.ts +67 -0
- package/dist/api/compiler/checker-symbol-types.js +1885 -0
- package/dist/api/compiler/checker-symbols.d.ts +181 -0
- package/dist/api/compiler/checker-symbols.js +1782 -0
- package/dist/api/compiler/checker-type-factory.d.ts +142 -0
- package/dist/api/compiler/checker-type-factory.js +2501 -0
- package/dist/api/compiler/checker-type-nodes.d.ts +26 -0
- package/dist/api/compiler/checker-type-nodes.js +828 -0
- package/dist/api/compiler/checker-type-operators.d.ts +109 -0
- package/dist/api/compiler/checker-type-operators.js +1842 -0
- package/dist/api/compiler/checker-types.d.ts +1027 -0
- package/dist/api/compiler/checker-types.js +1697 -0
- package/dist/api/compiler/checker-unused.d.ts +19 -0
- package/dist/api/compiler/checker-unused.js +524 -0
- package/dist/api/compiler/checker-utilities.d.ts +33 -0
- package/dist/api/compiler/checker-utilities.js +141 -0
- package/dist/api/compiler/checker.d.ts +491 -0
- package/dist/api/compiler/checker.js +912 -0
- package/dist/api/compiler/command-line.d.ts +32 -0
- package/dist/api/compiler/command-line.js +383 -0
- package/dist/api/compiler/compile-program.d.ts +118 -0
- package/dist/api/compiler/compile-program.js +384 -0
- package/dist/api/compiler/diagnostic-locales.d.ts +22 -0
- package/dist/api/compiler/diagnostic-locales.js +64 -0
- package/dist/api/compiler/diagnostic-messages.d.ts +2166 -0
- package/dist/api/compiler/diagnostic-messages.js +184 -0
- package/dist/api/compiler/diagnostics.d.ts +167 -0
- package/dist/api/compiler/diagnostics.js +820 -0
- package/dist/api/compiler/emitter.d.ts +71 -0
- package/dist/api/compiler/emitter.js +327 -0
- package/dist/api/compiler/file-include.d.ts +117 -0
- package/dist/api/compiler/file-include.js +536 -0
- package/dist/api/compiler/file-loader.d.ts +261 -0
- package/dist/api/compiler/file-loader.js +1257 -0
- package/dist/api/compiler/file-system.d.ts +51 -0
- package/dist/api/compiler/file-system.js +132 -0
- package/dist/api/compiler/flow.d.ts +60 -0
- package/dist/api/compiler/flow.js +45 -0
- package/dist/api/compiler/instantiation.d.ts +74 -0
- package/dist/api/compiler/instantiation.js +799 -0
- package/dist/api/compiler/jsdoc.d.ts +75 -0
- package/dist/api/compiler/jsdoc.js +1229 -0
- package/dist/api/compiler/link-tables.d.ts +36 -0
- package/dist/api/compiler/link-tables.js +83 -0
- package/dist/api/compiler/locale-data.d.ts +24 -0
- package/dist/api/compiler/locale-data.js +183 -0
- package/dist/api/compiler/locale.d.ts +4 -0
- package/dist/api/compiler/locale.js +317 -0
- package/dist/api/compiler/locales/cs-CZ.d.ts +2 -0
- package/dist/api/compiler/locales/cs-CZ.js +3 -0
- package/dist/api/compiler/locales/de-DE.d.ts +2 -0
- package/dist/api/compiler/locales/de-DE.js +3 -0
- package/dist/api/compiler/locales/es-ES.d.ts +2 -0
- package/dist/api/compiler/locales/es-ES.js +3 -0
- package/dist/api/compiler/locales/fr-FR.d.ts +2 -0
- package/dist/api/compiler/locales/fr-FR.js +3 -0
- package/dist/api/compiler/locales/it-IT.d.ts +2 -0
- package/dist/api/compiler/locales/it-IT.js +3 -0
- package/dist/api/compiler/locales/ja-JP.d.ts +2 -0
- package/dist/api/compiler/locales/ja-JP.js +3 -0
- package/dist/api/compiler/locales/ko-KR.d.ts +2 -0
- package/dist/api/compiler/locales/ko-KR.js +3 -0
- package/dist/api/compiler/locales/pl-PL.d.ts +2 -0
- package/dist/api/compiler/locales/pl-PL.js +3 -0
- package/dist/api/compiler/locales/pt-BR.d.ts +2 -0
- package/dist/api/compiler/locales/pt-BR.js +3 -0
- package/dist/api/compiler/locales/ru-RU.d.ts +2 -0
- package/dist/api/compiler/locales/ru-RU.js +3 -0
- package/dist/api/compiler/locales/tr-TR.d.ts +2 -0
- package/dist/api/compiler/locales/tr-TR.js +3 -0
- package/dist/api/compiler/locales/zh-CN.d.ts +2 -0
- package/dist/api/compiler/locales/zh-CN.js +3 -0
- package/dist/api/compiler/locales/zh-TW.d.ts +2 -0
- package/dist/api/compiler/locales/zh-TW.js +3 -0
- package/dist/api/compiler/module-resolution-types.d.ts +83 -0
- package/dist/api/compiler/module-resolution-types.js +176 -0
- package/dist/api/compiler/module-resolution.d.ts +71 -0
- package/dist/api/compiler/module-resolution.js +1598 -0
- package/dist/api/compiler/module-specifiers.d.ts +64 -0
- package/dist/api/compiler/module-specifiers.js +1101 -0
- package/dist/api/compiler/name-resolver.d.ts +43 -0
- package/dist/api/compiler/name-resolver.js +509 -0
- package/dist/api/compiler/node-builder-names.d.ts +32 -0
- package/dist/api/compiler/node-builder-names.js +854 -0
- package/dist/api/compiler/node-builder-pseudo.d.ts +36 -0
- package/dist/api/compiler/node-builder-pseudo.js +744 -0
- package/dist/api/compiler/node-builder-reuse.d.ts +4 -0
- package/dist/api/compiler/node-builder-reuse.js +647 -0
- package/dist/api/compiler/node-builder.d.ts +270 -0
- package/dist/api/compiler/node-builder.js +2645 -0
- package/dist/api/compiler/option-declarations.d.ts +90 -0
- package/dist/api/compiler/option-declarations.js +1460 -0
- package/dist/api/compiler/options.d.ts +289 -0
- package/dist/api/compiler/options.js +1197 -0
- package/dist/api/compiler/output-paths.d.ts +42 -0
- package/dist/api/compiler/output-paths.js +195 -0
- package/dist/api/compiler/package-json.d.ts +175 -0
- package/dist/api/compiler/package-json.js +1015 -0
- package/dist/api/compiler/parallel-parse.d.ts +219 -0
- package/dist/api/compiler/parallel-parse.js +537 -0
- package/dist/api/compiler/parser.d.ts +587 -0
- package/dist/api/compiler/parser.js +6407 -0
- package/dist/api/compiler/path.d.ts +91 -0
- package/dist/api/compiler/path.js +705 -0
- package/dist/api/compiler/printer/async-helpers.d.ts +22 -0
- package/dist/api/compiler/printer/async-helpers.js +91 -0
- package/dist/api/compiler/printer/auto-generate.d.ts +13 -0
- package/dist/api/compiler/printer/auto-generate.js +20 -0
- package/dist/api/compiler/printer/decorator-helpers.d.ts +24 -0
- package/dist/api/compiler/printer/decorator-helpers.js +118 -0
- package/dist/api/compiler/printer/emit-context.d.ts +154 -0
- package/dist/api/compiler/printer/emit-context.js +576 -0
- package/dist/api/compiler/printer/emit-flags.d.ts +60 -0
- package/dist/api/compiler/printer/emit-flags.js +2 -0
- package/dist/api/compiler/printer/factory-base.d.ts +171 -0
- package/dist/api/compiler/printer/factory-base.js +1505 -0
- package/dist/api/compiler/printer/factory.d.ts +147 -0
- package/dist/api/compiler/printer/factory.js +542 -0
- package/dist/api/compiler/printer/helpers.d.ts +27 -0
- package/dist/api/compiler/printer/helpers.js +164 -0
- package/dist/api/compiler/printer/name-generator.d.ts +41 -0
- package/dist/api/compiler/printer/name-generator.js +283 -0
- package/dist/api/compiler/printer/printer.d.ts +411 -0
- package/dist/api/compiler/printer/printer.js +4517 -0
- package/dist/api/compiler/printer/text-writer.d.ts +46 -0
- package/dist/api/compiler/printer/text-writer.js +172 -0
- package/dist/api/compiler/printer/utilities.d.ts +82 -0
- package/dist/api/compiler/printer/utilities.js +817 -0
- package/dist/api/compiler/program-checker.d.ts +156 -0
- package/dist/api/compiler/program-checker.js +526 -0
- package/dist/api/compiler/program-utilities.d.ts +52 -0
- package/dist/api/compiler/program-utilities.js +365 -0
- package/dist/api/compiler/program.d.ts +180 -0
- package/dist/api/compiler/program.js +1011 -0
- package/dist/api/compiler/pseudo-bigint.d.ts +5 -0
- package/dist/api/compiler/pseudo-bigint.js +61 -0
- package/dist/api/compiler/regexp-checker.d.ts +38 -0
- package/dist/api/compiler/regexp-checker.js +942 -0
- package/dist/api/compiler/relations.d.ts +263 -0
- package/dist/api/compiler/relations.js +4002 -0
- package/dist/api/compiler/reparser.d.ts +48 -0
- package/dist/api/compiler/reparser.js +1323 -0
- package/dist/api/compiler/scanner.d.ts +256 -0
- package/dist/api/compiler/scanner.js +2853 -0
- package/dist/api/compiler/side-state.d.ts +16 -0
- package/dist/api/compiler/side-state.js +89 -0
- package/dist/api/compiler/sourcemap.d.ts +55 -0
- package/dist/api/compiler/sourcemap.js +340 -0
- package/dist/api/compiler/spelling.d.ts +14 -0
- package/dist/api/compiler/spelling.js +128 -0
- package/dist/api/compiler/symbol-accessibility.d.ts +57 -0
- package/dist/api/compiler/symbol-accessibility.js +894 -0
- package/dist/api/compiler/symbol.d.ts +240 -0
- package/dist/api/compiler/symbol.js +228 -0
- package/dist/api/compiler/symlinks.d.ts +32 -0
- package/dist/api/compiler/symlinks.js +114 -0
- package/dist/api/compiler/syntax-kind.d.ts +389 -0
- package/dist/api/compiler/syntax-kind.js +2 -0
- package/dist/api/compiler/timeline.d.ts +9 -0
- package/dist/api/compiler/timeline.js +54 -0
- package/dist/api/compiler/transformers/alias-references.d.ts +39 -0
- package/dist/api/compiler/transformers/alias-references.js +676 -0
- package/dist/api/compiler/transformers/async-utilities.d.ts +51 -0
- package/dist/api/compiler/transformers/async-utilities.js +260 -0
- package/dist/api/compiler/transformers/async.d.ts +53 -0
- package/dist/api/compiler/transformers/async.js +645 -0
- package/dist/api/compiler/transformers/class-fields.d.ts +206 -0
- package/dist/api/compiler/transformers/class-fields.js +2418 -0
- package/dist/api/compiler/transformers/class-utilities.d.ts +46 -0
- package/dist/api/compiler/transformers/class-utilities.js +261 -0
- package/dist/api/compiler/transformers/commonjs-module.d.ts +103 -0
- package/dist/api/compiler/transformers/commonjs-module.js +1180 -0
- package/dist/api/compiler/transformers/const-enum-inliner.d.ts +11 -0
- package/dist/api/compiler/transformers/const-enum-inliner.js +36 -0
- package/dist/api/compiler/transformers/declarations-diagnostics.d.ts +52 -0
- package/dist/api/compiler/transformers/declarations-diagnostics.js +538 -0
- package/dist/api/compiler/transformers/declarations-pseudo.d.ts +160 -0
- package/dist/api/compiler/transformers/declarations-pseudo.js +797 -0
- package/dist/api/compiler/transformers/declarations-resolver.d.ts +152 -0
- package/dist/api/compiler/transformers/declarations-resolver.js +35 -0
- package/dist/api/compiler/transformers/declarations-syntactic.d.ts +119 -0
- package/dist/api/compiler/transformers/declarations-syntactic.js +1582 -0
- package/dist/api/compiler/transformers/declarations-tracker.d.ts +46 -0
- package/dist/api/compiler/transformers/declarations-tracker.js +197 -0
- package/dist/api/compiler/transformers/declarations.d.ts +175 -0
- package/dist/api/compiler/transformers/declarations.js +2380 -0
- package/dist/api/compiler/transformers/decorator-metadata.d.ts +54 -0
- package/dist/api/compiler/transformers/decorator-metadata.js +554 -0
- package/dist/api/compiler/transformers/decorator-utilities.d.ts +38 -0
- package/dist/api/compiler/transformers/decorator-utilities.js +238 -0
- package/dist/api/compiler/transformers/destructuring.d.ts +25 -0
- package/dist/api/compiler/transformers/destructuring.js +626 -0
- package/dist/api/compiler/transformers/downlevel.d.ts +6 -0
- package/dist/api/compiler/transformers/downlevel.js +45 -0
- package/dist/api/compiler/transformers/emit-resolver.d.ts +61 -0
- package/dist/api/compiler/transformers/emit-resolver.js +197 -0
- package/dist/api/compiler/transformers/es-decorators.d.ts +118 -0
- package/dist/api/compiler/transformers/es-decorators.js +1901 -0
- package/dist/api/compiler/transformers/exponentiation.d.ts +11 -0
- package/dist/api/compiler/transformers/exponentiation.js +76 -0
- package/dist/api/compiler/transformers/external-module-info.d.ts +35 -0
- package/dist/api/compiler/transformers/external-module-info.js +351 -0
- package/dist/api/compiler/transformers/for-await.d.ts +43 -0
- package/dist/api/compiler/transformers/for-await.js +469 -0
- package/dist/api/compiler/transformers/import-elision.d.ts +16 -0
- package/dist/api/compiler/transformers/import-elision.js +124 -0
- package/dist/api/compiler/transformers/jsx-entities.d.ts +1 -0
- package/dist/api/compiler/transformers/jsx-entities.js +256 -0
- package/dist/api/compiler/transformers/jsx.d.ts +71 -0
- package/dist/api/compiler/transformers/jsx.js +700 -0
- package/dist/api/compiler/transformers/legacy-decorators.d.ts +56 -0
- package/dist/api/compiler/transformers/legacy-decorators.js +564 -0
- package/dist/api/compiler/transformers/logical-assignment.d.ts +14 -0
- package/dist/api/compiler/transformers/logical-assignment.js +62 -0
- package/dist/api/compiler/transformers/module-utilities.d.ts +9 -0
- package/dist/api/compiler/transformers/module-utilities.js +36 -0
- package/dist/api/compiler/transformers/module.d.ts +49 -0
- package/dist/api/compiler/transformers/module.js +296 -0
- package/dist/api/compiler/transformers/named-evaluation.d.ts +26 -0
- package/dist/api/compiler/transformers/named-evaluation.js +266 -0
- package/dist/api/compiler/transformers/nullish-coalescing.d.ts +9 -0
- package/dist/api/compiler/transformers/nullish-coalescing.js +26 -0
- package/dist/api/compiler/transformers/object-rest-spread.d.ts +34 -0
- package/dist/api/compiler/transformers/object-rest-spread.js +411 -0
- package/dist/api/compiler/transformers/optional-catch.d.ts +9 -0
- package/dist/api/compiler/transformers/optional-catch.js +20 -0
- package/dist/api/compiler/transformers/optional-chain.d.ts +14 -0
- package/dist/api/compiler/transformers/optional-chain.js +188 -0
- package/dist/api/compiler/transformers/reference-resolver.d.ts +128 -0
- package/dist/api/compiler/transformers/reference-resolver.js +1155 -0
- package/dist/api/compiler/transformers/runtime-syntax.d.ts +71 -0
- package/dist/api/compiler/transformers/runtime-syntax.js +753 -0
- package/dist/api/compiler/transformers/subtree-facts.d.ts +9 -0
- package/dist/api/compiler/transformers/subtree-facts.js +203 -0
- package/dist/api/compiler/transformers/syntax-facts.d.ts +51 -0
- package/dist/api/compiler/transformers/syntax-facts.js +254 -0
- package/dist/api/compiler/transformers/tagged-template.d.ts +17 -0
- package/dist/api/compiler/transformers/tagged-template.js +148 -0
- package/dist/api/compiler/transformers/transformer.d.ts +17 -0
- package/dist/api/compiler/transformers/transformer.js +54 -0
- package/dist/api/compiler/transformers/type-eraser.d.ts +21 -0
- package/dist/api/compiler/transformers/type-eraser.js +346 -0
- package/dist/api/compiler/transformers/type-serialization.d.ts +20 -0
- package/dist/api/compiler/transformers/type-serialization.js +347 -0
- package/dist/api/compiler/transformers/using.d.ts +56 -0
- package/dist/api/compiler/transformers/using.js +453 -0
- package/dist/api/compiler/transformers/utilities.d.ts +50 -0
- package/dist/api/compiler/transformers/utilities.js +347 -0
- package/dist/api/compiler/transformers/visitor-base.d.ts +6 -0
- package/dist/api/compiler/transformers/visitor-base.js +817 -0
- package/dist/api/compiler/transformers/visitor-hooks.d.ts +29 -0
- package/dist/api/compiler/transformers/visitor-hooks.js +189 -0
- package/dist/api/compiler/tsconfig.d.ts +177 -0
- package/dist/api/compiler/tsconfig.js +1311 -0
- package/dist/api/compiler/type-printer.d.ts +15 -0
- package/dist/api/compiler/type-printer.js +74 -0
- package/dist/api/compiler/types.d.ts +87 -0
- package/dist/api/compiler/types.js +23 -0
- package/dist/api/compiler/unicode-identifiers.d.ts +2 -0
- package/dist/api/compiler/unicode-identifiers.js +209 -0
- package/dist/api/compiler/unicode-properties.d.ts +8 -0
- package/dist/api/compiler/unicode-properties.js +531 -0
- package/dist/api/compiler/vfs-match.d.ts +24 -0
- package/dist/api/compiler/vfs-match.js +587 -0
- package/dist/api/library/ast.d.ts +3 -2
- package/dist/api/library/ast.generated.d.ts +127 -139
- package/dist/api/library/checker.d.ts +51 -0
- package/dist/api/library/checker.js +318 -0
- package/dist/api/library/diagnostics.d.ts +13 -0
- package/dist/api/library/diagnostics.js +50 -0
- package/dist/api/library/disk.d.ts +13 -0
- package/dist/api/library/disk.js +66 -0
- package/dist/api/library/errors.d.ts +13 -0
- package/dist/api/library/errors.js +24 -0
- package/dist/api/library/host.d.ts +24 -0
- package/dist/api/library/host.js +52 -0
- package/dist/api/library/index.d.ts +5 -1
- package/dist/api/library/index.js +4 -0
- package/dist/api/library/nodes.d.ts +51 -0
- package/dist/api/library/nodes.js +196 -0
- package/dist/api/library/options.d.ts +144 -0
- package/dist/api/library/options.js +308 -0
- package/dist/api/library/parse.d.ts +19 -0
- package/dist/api/library/parse.js +41 -0
- package/dist/api/library/program.d.ts +21 -0
- package/dist/api/library/program.js +234 -0
- package/dist/api/library/types.d.ts +14 -1
- package/package.json +12 -8
- package/src/compiler/ast-utilities.ts +548 -0
- package/src/compiler/ast.ts +12862 -0
- package/src/compiler/astnav.ts +799 -0
- package/src/compiler/binder-utilities.ts +1392 -0
- package/src/compiler/binder.ts +2703 -0
- package/src/compiler/build-info.ts +1197 -0
- package/src/compiler/character-codes.ts +323 -0
- package/src/compiler/checker-calls.ts +2155 -0
- package/src/compiler/checker-classes.ts +706 -0
- package/src/compiler/checker-contextual.ts +1457 -0
- package/src/compiler/checker-declaration-order.ts +438 -0
- package/src/compiler/checker-declarations.ts +1194 -0
- package/src/compiler/checker-declared-types.ts +919 -0
- package/src/compiler/checker-decorators.ts +694 -0
- package/src/compiler/checker-deprecation.ts +359 -0
- package/src/compiler/checker-destructuring.ts +805 -0
- package/src/compiler/checker-elaboration.ts +477 -0
- package/src/compiler/checker-emit-helpers.ts +224 -0
- package/src/compiler/checker-emit-resolver.ts +769 -0
- package/src/compiler/checker-evaluator.ts +243 -0
- package/src/compiler/checker-expressions.ts +1831 -0
- package/src/compiler/checker-features.ts +361 -0
- package/src/compiler/checker-flow.ts +394 -0
- package/src/compiler/checker-functions.ts +1296 -0
- package/src/compiler/checker-generated-code.ts +227 -0
- package/src/compiler/checker-globals.ts +52 -0
- package/src/compiler/checker-grammar.ts +3584 -0
- package/src/compiler/checker-heritage.ts +1233 -0
- package/src/compiler/checker-inference.ts +2576 -0
- package/src/compiler/checker-iteration.ts +1206 -0
- package/src/compiler/checker-javascript.ts +502 -0
- package/src/compiler/checker-jsdoc.ts +360 -0
- package/src/compiler/checker-jsx.ts +1924 -0
- package/src/compiler/checker-literals.ts +61 -0
- package/src/compiler/checker-members.ts +2436 -0
- package/src/compiler/checker-modules.ts +2886 -0
- package/src/compiler/checker-narrowing.ts +3230 -0
- package/src/compiler/checker-object-literals.ts +575 -0
- package/src/compiler/checker-operators.ts +1422 -0
- package/src/compiler/checker-overloads.ts +328 -0
- package/src/compiler/checker-property-access.ts +906 -0
- package/src/compiler/checker-services.ts +1149 -0
- package/src/compiler/checker-signatures.ts +1032 -0
- package/src/compiler/checker-source-file.ts +732 -0
- package/src/compiler/checker-statements.ts +292 -0
- package/src/compiler/checker-super.ts +261 -0
- package/src/compiler/checker-symbol-types.ts +2107 -0
- package/src/compiler/checker-symbols.ts +2150 -0
- package/src/compiler/checker-type-factory.ts +2579 -0
- package/src/compiler/checker-type-nodes.ts +1033 -0
- package/src/compiler/checker-type-operators.ts +2502 -0
- package/src/compiler/checker-types.ts +2340 -0
- package/src/compiler/checker-unused.ts +642 -0
- package/src/compiler/checker-utilities.ts +161 -0
- package/src/compiler/checker.ts +1116 -0
- package/src/compiler/command-line.ts +436 -0
- package/src/compiler/compile-program.ts +439 -0
- package/src/compiler/decoder.ts +1209 -0
- package/src/compiler/diagnostic-locales.ts +86 -0
- package/src/compiler/diagnostic-messages.ts +2349 -0
- package/src/compiler/diagnostics.ts +897 -0
- package/src/compiler/emitter.ts +434 -0
- package/src/compiler/encoder.ts +1945 -0
- package/src/compiler/file-include.ts +673 -0
- package/src/compiler/file-loader.ts +1528 -0
- package/src/compiler/file-system.ts +143 -0
- package/src/compiler/flow.ts +89 -0
- package/src/compiler/help.ts +473 -0
- package/src/compiler/incremental.ts +2784 -0
- package/src/compiler/init.ts +141 -0
- package/src/compiler/instantiation.ts +894 -0
- package/src/compiler/jsdoc.ts +1386 -0
- package/src/compiler/link-tables.ts +98 -0
- package/src/compiler/locale-data.ts +203 -0
- package/src/compiler/locale.ts +307 -0
- package/src/compiler/locales/cs-CZ.ts +5 -0
- package/src/compiler/locales/de-DE.ts +5 -0
- package/src/compiler/locales/es-ES.ts +5 -0
- package/src/compiler/locales/fr-FR.ts +5 -0
- package/src/compiler/locales/it-IT.ts +5 -0
- package/src/compiler/locales/ja-JP.ts +5 -0
- package/src/compiler/locales/ko-KR.ts +5 -0
- package/src/compiler/locales/pl-PL.ts +5 -0
- package/src/compiler/locales/pt-BR.ts +5 -0
- package/src/compiler/locales/ru-RU.ts +5 -0
- package/src/compiler/locales/tr-TR.ts +5 -0
- package/src/compiler/locales/zh-CN.ts +5 -0
- package/src/compiler/locales/zh-TW.ts +5 -0
- package/src/compiler/module-resolution-types.ts +243 -0
- package/src/compiler/module-resolution.ts +2072 -0
- package/src/compiler/module-specifiers.ts +1491 -0
- package/src/compiler/name-resolver.ts +646 -0
- package/src/compiler/node-builder-names.ts +1069 -0
- package/src/compiler/node-builder-pseudo.ts +892 -0
- package/src/compiler/node-builder-reuse.ts +764 -0
- package/src/compiler/node-builder.ts +3425 -0
- package/src/compiler/option-declarations.ts +1560 -0
- package/src/compiler/options.ts +1576 -0
- package/src/compiler/output-paths.ts +334 -0
- package/src/compiler/package-json.ts +1083 -0
- package/src/compiler/parallel-check.ts +1951 -0
- package/src/compiler/parallel-parse.ts +590 -0
- package/src/compiler/parse-thread.ts +140 -0
- package/src/compiler/parser.ts +7716 -0
- package/src/compiler/path.ts +717 -0
- package/src/compiler/printer/async-helpers.ts +183 -0
- package/src/compiler/printer/auto-generate.ts +27 -0
- package/src/compiler/printer/decorator-helpers.ts +218 -0
- package/src/compiler/printer/emit-context.ts +679 -0
- package/src/compiler/printer/emit-flags.ts +64 -0
- package/src/compiler/printer/factory-base.ts +2577 -0
- package/src/compiler/printer/factory.ts +764 -0
- package/src/compiler/printer/helpers.ts +291 -0
- package/src/compiler/printer/name-generator.ts +372 -0
- package/src/compiler/printer/printer.ts +5072 -0
- package/src/compiler/printer/text-writer.ts +183 -0
- package/src/compiler/printer/utilities.ts +884 -0
- package/src/compiler/program-checker.ts +592 -0
- package/src/compiler/program-utilities.ts +435 -0
- package/src/compiler/program.ts +1419 -0
- package/src/compiler/pseudo-bigint.ts +62 -0
- package/src/compiler/regexp-checker.ts +1142 -0
- package/src/compiler/relations.ts +5149 -0
- package/src/compiler/reparser.ts +1566 -0
- package/src/compiler/scanner.ts +2951 -0
- package/src/compiler/show-config.ts +239 -0
- package/src/compiler/side-state.ts +125 -0
- package/src/compiler/sourcemap.ts +366 -0
- package/src/compiler/spelling.ts +122 -0
- package/src/compiler/symbol-accessibility.ts +1071 -0
- package/src/compiler/symbol.ts +439 -0
- package/src/compiler/symlinks.ts +137 -0
- package/src/compiler/syntax-kind.ts +391 -0
- package/src/compiler/thread-entry.ts +191 -0
- package/src/compiler/timeline.ts +53 -0
- package/src/compiler/transformers/alias-references.ts +757 -0
- package/src/compiler/transformers/async-utilities.ts +335 -0
- package/src/compiler/transformers/async.ts +838 -0
- package/src/compiler/transformers/class-fields.ts +2967 -0
- package/src/compiler/transformers/class-utilities.ts +324 -0
- package/src/compiler/transformers/commonjs-module.ts +1621 -0
- package/src/compiler/transformers/const-enum-inliner.ts +50 -0
- package/src/compiler/transformers/declarations-diagnostics.ts +832 -0
- package/src/compiler/transformers/declarations-pseudo.ts +966 -0
- package/src/compiler/transformers/declarations-resolver.ts +249 -0
- package/src/compiler/transformers/declarations-syntactic.ts +1859 -0
- package/src/compiler/transformers/declarations-tracker.ts +269 -0
- package/src/compiler/transformers/declarations.ts +3120 -0
- package/src/compiler/transformers/decorator-metadata.ts +697 -0
- package/src/compiler/transformers/decorator-utilities.ts +283 -0
- package/src/compiler/transformers/destructuring.ts +708 -0
- package/src/compiler/transformers/downlevel.ts +50 -0
- package/src/compiler/transformers/emit-resolver.ts +258 -0
- package/src/compiler/transformers/es-decorators.ts +2682 -0
- package/src/compiler/transformers/exponentiation.ts +80 -0
- package/src/compiler/transformers/external-module-info.ts +412 -0
- package/src/compiler/transformers/for-await.ts +687 -0
- package/src/compiler/transformers/import-elision.ts +152 -0
- package/src/compiler/transformers/jsx-entities.ts +256 -0
- package/src/compiler/transformers/jsx.ts +824 -0
- package/src/compiler/transformers/legacy-decorators.ts +726 -0
- package/src/compiler/transformers/logical-assignment.ts +75 -0
- package/src/compiler/transformers/module-utilities.ts +42 -0
- package/src/compiler/transformers/module.ts +474 -0
- package/src/compiler/transformers/named-evaluation.ts +389 -0
- package/src/compiler/transformers/nullish-coalescing.ts +35 -0
- package/src/compiler/transformers/object-rest-spread.ts +577 -0
- package/src/compiler/transformers/optional-catch.ts +29 -0
- package/src/compiler/transformers/optional-chain.ts +246 -0
- package/src/compiler/transformers/reference-resolver.ts +1201 -0
- package/src/compiler/transformers/runtime-syntax.ts +942 -0
- package/src/compiler/transformers/subtree-facts.ts +245 -0
- package/src/compiler/transformers/syntax-facts.ts +353 -0
- package/src/compiler/transformers/tagged-template.ts +167 -0
- package/src/compiler/transformers/transformer.ts +56 -0
- package/src/compiler/transformers/type-eraser.ts +520 -0
- package/src/compiler/transformers/type-serialization.ts +374 -0
- package/src/compiler/transformers/using.ts +613 -0
- package/src/compiler/transformers/utilities.ts +419 -0
- package/src/compiler/transformers/visitor-base.ts +1601 -0
- package/src/compiler/transformers/visitor-hooks.ts +252 -0
- package/src/compiler/tsc-build.ts +1418 -0
- package/src/compiler/tsc-cli.ts +666 -0
- package/src/compiler/tsc-compile.ts +437 -0
- package/src/compiler/tsc-watch.ts +854 -0
- package/src/compiler/tsconfig.ts +1574 -0
- package/src/compiler/type-printer.ts +110 -0
- package/src/compiler/types.ts +115 -0
- package/src/compiler/unicode-identifiers.ts +212 -0
- package/src/compiler/unicode-properties.ts +537 -0
- package/src/compiler/vfs-match.ts +597 -0
- package/src/compiler/xxh3.ts +650 -0
- package/src/library/ast.generated.ts +141 -167
- package/src/library/ast.ts +4 -1
- package/src/library/checker.ts +384 -0
- package/src/library/diagnostics.ts +72 -0
- package/src/library/disk.ts +73 -0
- package/src/library/errors.ts +26 -0
- package/src/library/host.ts +63 -0
- package/src/library/index.ts +21 -0
- package/src/library/nodes.ts +232 -0
- package/src/library/options.ts +449 -0
- package/src/library/parse.ts +63 -0
- package/src/library/program.ts +293 -0
- package/src/library/types.ts +14 -1
|
@@ -0,0 +1,942 @@
|
|
|
1
|
+
import { charSize, codePointAt, isASCIILetter, isDigit, isIdentifierPart, isWordCharacter, } from './character-codes.js';
|
|
2
|
+
import { getSpellingSuggestion } from './spelling.js';
|
|
3
|
+
import { binaryUnicodeProperties, binaryUnicodePropertiesOfStrings, generalCategoryValues, nonBinaryUnicodeProperties, valuesOfNonBinaryUnicodeProperty, } from './unicode-properties.js';
|
|
4
|
+
/** The flag for a regular expression flag character, or `None`. */
|
|
5
|
+
export function regularExpressionFlag(ch) {
|
|
6
|
+
switch (ch) {
|
|
7
|
+
case 100 /* CharacterCodes.d */:
|
|
8
|
+
return 1 /* RegularExpressionFlags.HasIndices */;
|
|
9
|
+
case 103 /* CharacterCodes.g */:
|
|
10
|
+
return 2 /* RegularExpressionFlags.Global */;
|
|
11
|
+
case 105 /* CharacterCodes.i */:
|
|
12
|
+
return 4 /* RegularExpressionFlags.IgnoreCase */;
|
|
13
|
+
case 109 /* CharacterCodes.m */:
|
|
14
|
+
return 8 /* RegularExpressionFlags.Multiline */;
|
|
15
|
+
case 115 /* CharacterCodes.s */:
|
|
16
|
+
return 16 /* RegularExpressionFlags.DotAll */;
|
|
17
|
+
case 117 /* CharacterCodes.u */:
|
|
18
|
+
return 32 /* RegularExpressionFlags.Unicode */;
|
|
19
|
+
case 118 /* CharacterCodes.v */:
|
|
20
|
+
return 64 /* RegularExpressionFlags.UnicodeSets */;
|
|
21
|
+
case 121 /* CharacterCodes.y */:
|
|
22
|
+
return 128 /* RegularExpressionFlags.Sticky */;
|
|
23
|
+
default:
|
|
24
|
+
return 0 /* RegularExpressionFlags.None */;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
class GroupNameReference {
|
|
28
|
+
pos;
|
|
29
|
+
end;
|
|
30
|
+
name;
|
|
31
|
+
constructor(pos, end, name) {
|
|
32
|
+
this.pos = pos;
|
|
33
|
+
this.end = end;
|
|
34
|
+
this.name = name;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
class DecimalEscape {
|
|
38
|
+
pos;
|
|
39
|
+
end;
|
|
40
|
+
value;
|
|
41
|
+
constructor(pos, end, value) {
|
|
42
|
+
this.pos = pos;
|
|
43
|
+
this.end = end;
|
|
44
|
+
this.value = value;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const noArgs = [];
|
|
48
|
+
/**
|
|
49
|
+
* Checks the body of a regular expression literal, which the scanner has bounded
|
|
50
|
+
* to `[scanner.pos, end)`, and reports syntax errors through the scanner.
|
|
51
|
+
*/
|
|
52
|
+
export function checkRegularExpression(scanner, end, flags, namedCaptureGroups) {
|
|
53
|
+
new RegularExpressionChecker(scanner, end, flags, namedCaptureGroups).check();
|
|
54
|
+
}
|
|
55
|
+
function compareDecimalStrings(a, b) {
|
|
56
|
+
let i = 0;
|
|
57
|
+
while (i < a.length && a.charCodeAt(i) === 48 /* CharacterCodes._0 */)
|
|
58
|
+
i++;
|
|
59
|
+
let j = 0;
|
|
60
|
+
while (j < b.length && b.charCodeAt(j) === 48 /* CharacterCodes._0 */)
|
|
61
|
+
j++;
|
|
62
|
+
const x = i === a.length ? '0' : a.substring(i);
|
|
63
|
+
const y = j === b.length ? '0' : b.substring(j);
|
|
64
|
+
if (x.length !== y.length)
|
|
65
|
+
return x.length < y.length ? -1 : 1;
|
|
66
|
+
return x < y ? -1 : x > y ? 1 : 0;
|
|
67
|
+
}
|
|
68
|
+
function mapKeys(map) {
|
|
69
|
+
const result = [];
|
|
70
|
+
for (const key of map.keys())
|
|
71
|
+
result.push(key);
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
function setToArray(set) {
|
|
75
|
+
const result = [];
|
|
76
|
+
for (const value of set)
|
|
77
|
+
result.push(value);
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
class RegularExpressionChecker {
|
|
81
|
+
scanner;
|
|
82
|
+
text;
|
|
83
|
+
end;
|
|
84
|
+
anyUnicodeMode;
|
|
85
|
+
unicodeSetsMode;
|
|
86
|
+
annexB;
|
|
87
|
+
// Checked strictly in Unicode modes or without Annex B's looser grammar.
|
|
88
|
+
anyUnicodeModeOrNonAnnexB;
|
|
89
|
+
namedCaptureGroups;
|
|
90
|
+
// See scanClassSetExpression.
|
|
91
|
+
mayContainStrings;
|
|
92
|
+
numberOfCapturingGroups;
|
|
93
|
+
groupSpecifiers;
|
|
94
|
+
groupNameReferences;
|
|
95
|
+
decimalEscapes;
|
|
96
|
+
// Scopes of named capturing groups; see scanGroupName.
|
|
97
|
+
namedCapturingGroups;
|
|
98
|
+
constructor(scanner, end, flags, namedCaptureGroups) {
|
|
99
|
+
this.scanner = scanner;
|
|
100
|
+
this.text = scanner.text;
|
|
101
|
+
this.end = end;
|
|
102
|
+
this.anyUnicodeMode = (flags & 96 /* RegularExpressionFlags.AnyUnicodeMode */) !== 0;
|
|
103
|
+
this.unicodeSetsMode = (flags & 64 /* RegularExpressionFlags.UnicodeSets */) !== 0;
|
|
104
|
+
this.annexB = true;
|
|
105
|
+
this.anyUnicodeModeOrNonAnnexB = this.anyUnicodeMode || !this.annexB;
|
|
106
|
+
this.namedCaptureGroups = namedCaptureGroups;
|
|
107
|
+
this.mayContainStrings = false;
|
|
108
|
+
this.numberOfCapturingGroups = 0;
|
|
109
|
+
this.groupSpecifiers = new Set();
|
|
110
|
+
this.groupNameReferences = [];
|
|
111
|
+
this.decimalEscapes = [];
|
|
112
|
+
this.namedCapturingGroups = [];
|
|
113
|
+
}
|
|
114
|
+
char() {
|
|
115
|
+
return this.scanner.char();
|
|
116
|
+
}
|
|
117
|
+
/** The code unit at absolute position `pos`, or -1 past the body. */
|
|
118
|
+
charAt(pos) {
|
|
119
|
+
return pos < this.end ? this.text.charCodeAt(pos) : -1 /* CharacterCodes.EOF */;
|
|
120
|
+
}
|
|
121
|
+
error(message, start, length, args) {
|
|
122
|
+
this.scanner.errorAt(message, start, length, args);
|
|
123
|
+
}
|
|
124
|
+
/** Checks the expression and returns its number of capturing groups. */
|
|
125
|
+
check() {
|
|
126
|
+
this.scanDisjunction(false);
|
|
127
|
+
for (const reference of this.groupNameReferences) {
|
|
128
|
+
if (this.groupSpecifiers.has(reference.name))
|
|
129
|
+
continue;
|
|
130
|
+
this.error(447 /* Diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression */, reference.pos, reference.end - reference.pos, [reference.name]);
|
|
131
|
+
if (this.groupSpecifiers.size > 0) {
|
|
132
|
+
const suggestion = getSpellingSuggestion(reference.name, setToArray(this.groupSpecifiers));
|
|
133
|
+
if (suggestion !== '')
|
|
134
|
+
this.error(303 /* Diagnostics.Did_you_mean_0 */, reference.pos, reference.end - reference.pos, [suggestion]);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Annex B reads such escapes as octal or identity escapes, but they are most likely mistakes.
|
|
138
|
+
for (const escape of this.decimalEscapes) {
|
|
139
|
+
if (escape.value <= this.numberOfCapturingGroups)
|
|
140
|
+
continue;
|
|
141
|
+
if (this.numberOfCapturingGroups > 0)
|
|
142
|
+
this.error(448 /* Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression */, escape.pos, escape.end - escape.pos, [String(this.numberOfCapturingGroups)]);
|
|
143
|
+
else
|
|
144
|
+
this.error(449 /* Diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_no_capturing_groups_in_this_regular_expression */, escape.pos, escape.end - escape.pos, noArgs);
|
|
145
|
+
}
|
|
146
|
+
return this.numberOfCapturingGroups;
|
|
147
|
+
}
|
|
148
|
+
// Disjunction ::= Alternative ('|' Alternative)*
|
|
149
|
+
scanDisjunction(isInGroup) {
|
|
150
|
+
for (;;) {
|
|
151
|
+
this.namedCapturingGroups.push(new Set());
|
|
152
|
+
this.scanAlternative(isInGroup);
|
|
153
|
+
this.namedCapturingGroups.pop();
|
|
154
|
+
if (this.char() !== 124 /* CharacterCodes.bar */)
|
|
155
|
+
return;
|
|
156
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Alternative ::= Term*
|
|
160
|
+
// Term ::= Assertion | Atom Quantifier?
|
|
161
|
+
scanAlternative(isInGroup) {
|
|
162
|
+
let isPreviousTermQuantifiable = false;
|
|
163
|
+
while (this.scanner.pos < this.end) {
|
|
164
|
+
const start = this.scanner.pos;
|
|
165
|
+
const ch = this.char();
|
|
166
|
+
switch (ch) {
|
|
167
|
+
case 94 /* CharacterCodes.caret */:
|
|
168
|
+
case 36 /* CharacterCodes.$ */:
|
|
169
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
170
|
+
isPreviousTermQuantifiable = false;
|
|
171
|
+
continue;
|
|
172
|
+
case 92 /* CharacterCodes.backslash */:
|
|
173
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
174
|
+
if (this.char() === 98 /* CharacterCodes.b */ || this.char() === 66 /* CharacterCodes.B */) {
|
|
175
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
176
|
+
isPreviousTermQuantifiable = false;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
this.scanAtomEscape(this.char());
|
|
180
|
+
isPreviousTermQuantifiable = true;
|
|
181
|
+
}
|
|
182
|
+
continue;
|
|
183
|
+
case 40 /* CharacterCodes.openParen */:
|
|
184
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
185
|
+
if (this.char() === 63 /* CharacterCodes.question */) {
|
|
186
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
187
|
+
const next = this.char();
|
|
188
|
+
if (next === 61 /* CharacterCodes.equals */ || next === 33 /* CharacterCodes.exclamation */) {
|
|
189
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
190
|
+
// Annex B makes `(?=…)` and `(?!…)` quantifiable.
|
|
191
|
+
isPreviousTermQuantifiable = !this.anyUnicodeModeOrNonAnnexB;
|
|
192
|
+
}
|
|
193
|
+
else if (next === 60 /* CharacterCodes.lessThan */) {
|
|
194
|
+
const groupNameStart = this.scanner.pos;
|
|
195
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
196
|
+
if (this.char() === 61 /* CharacterCodes.equals */ || this.char() === 33 /* CharacterCodes.exclamation */) {
|
|
197
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
198
|
+
isPreviousTermQuantifiable = false;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
this.scanGroupName(false);
|
|
202
|
+
this.scanExpectedChar(62 /* CharacterCodes.greaterThan */);
|
|
203
|
+
if (this.scanner.languageVersion() < 5 /* ScriptTarget.ES2018 */)
|
|
204
|
+
this.error(418 /* Diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later */, groupNameStart, this.scanner.pos - groupNameStart, noArgs);
|
|
205
|
+
this.numberOfCapturingGroups++;
|
|
206
|
+
isPreviousTermQuantifiable = true;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const flagsStart = this.scanner.pos;
|
|
211
|
+
const setFlags = this.scanPatternModifiers(0 /* RegularExpressionFlags.None */);
|
|
212
|
+
if (this.char() === 45 /* CharacterCodes.minus */) {
|
|
213
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
214
|
+
this.scanPatternModifiers(setFlags);
|
|
215
|
+
if (this.scanner.pos === flagsStart + 1)
|
|
216
|
+
this.error(419 /* Diagnostics.Subpattern_flags_must_be_present_when_there_is_a_minus_sign */, flagsStart, this.scanner.pos - flagsStart, noArgs);
|
|
217
|
+
}
|
|
218
|
+
this.scanExpectedChar(58 /* CharacterCodes.colon */);
|
|
219
|
+
isPreviousTermQuantifiable = true;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
this.numberOfCapturingGroups++;
|
|
224
|
+
isPreviousTermQuantifiable = true;
|
|
225
|
+
}
|
|
226
|
+
this.scanDisjunction(true);
|
|
227
|
+
this.scanExpectedChar(41 /* CharacterCodes.closeParen */);
|
|
228
|
+
continue;
|
|
229
|
+
case 123 /* CharacterCodes.openBrace */: {
|
|
230
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
231
|
+
const digitsStart = this.scanner.pos;
|
|
232
|
+
const min = this.scanDigits();
|
|
233
|
+
if (!this.anyUnicodeModeOrNonAnnexB && min === '') {
|
|
234
|
+
isPreviousTermQuantifiable = true;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (this.char() === 44 /* CharacterCodes.comma */) {
|
|
238
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
239
|
+
const max = this.scanDigits();
|
|
240
|
+
if (min === '') {
|
|
241
|
+
if (max !== '' || this.char() === 125 /* CharacterCodes.closeBrace */) {
|
|
242
|
+
this.error(420 /* Diagnostics.Incomplete_quantifier_Digit_expected */, digitsStart, 0, noArgs);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, start, 1, [
|
|
246
|
+
String.fromCharCode(ch),
|
|
247
|
+
]);
|
|
248
|
+
isPreviousTermQuantifiable = true;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else if (max !== '' &&
|
|
253
|
+
compareDecimalStrings(min, max) > 0 &&
|
|
254
|
+
(this.anyUnicodeModeOrNonAnnexB || this.char() === 125 /* CharacterCodes.closeBrace */)) {
|
|
255
|
+
this.error(421 /* Diagnostics.Numbers_out_of_order_in_quantifier */, digitsStart, this.scanner.pos - digitsStart, noArgs);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
else if (min === '') {
|
|
259
|
+
if (this.anyUnicodeModeOrNonAnnexB)
|
|
260
|
+
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, start, 1, [
|
|
261
|
+
String.fromCharCode(ch),
|
|
262
|
+
]);
|
|
263
|
+
isPreviousTermQuantifiable = true;
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (this.char() !== 125 /* CharacterCodes.closeBrace */) {
|
|
267
|
+
if (!this.anyUnicodeModeOrNonAnnexB) {
|
|
268
|
+
isPreviousTermQuantifiable = true;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
this.error(2 /* Diagnostics.X_0_expected */, this.scanner.pos, 0, ['}']);
|
|
272
|
+
this.scanner.pos = (this.scanner.pos - 1) | 0;
|
|
273
|
+
}
|
|
274
|
+
isPreviousTermQuantifiable = this.scanQuantifier(start, isPreviousTermQuantifiable);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
case 42 /* CharacterCodes.asterisk */:
|
|
278
|
+
case 43 /* CharacterCodes.plus */:
|
|
279
|
+
case 63 /* CharacterCodes.question */:
|
|
280
|
+
isPreviousTermQuantifiable = this.scanQuantifier(start, isPreviousTermQuantifiable);
|
|
281
|
+
continue;
|
|
282
|
+
case 46 /* CharacterCodes.dot */:
|
|
283
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
284
|
+
isPreviousTermQuantifiable = true;
|
|
285
|
+
continue;
|
|
286
|
+
case 91 /* CharacterCodes.openBracket */:
|
|
287
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
288
|
+
if (this.unicodeSetsMode)
|
|
289
|
+
this.scanClassSetExpression();
|
|
290
|
+
else
|
|
291
|
+
this.scanClassRanges();
|
|
292
|
+
this.scanExpectedChar(93 /* CharacterCodes.closeBracket */);
|
|
293
|
+
isPreviousTermQuantifiable = true;
|
|
294
|
+
continue;
|
|
295
|
+
case 41 /* CharacterCodes.closeParen */:
|
|
296
|
+
case 93 /* CharacterCodes.closeBracket */:
|
|
297
|
+
case 125 /* CharacterCodes.closeBrace */:
|
|
298
|
+
if (ch === 41 /* CharacterCodes.closeParen */ && isInGroup)
|
|
299
|
+
return;
|
|
300
|
+
if (this.anyUnicodeModeOrNonAnnexB || ch === 41 /* CharacterCodes.closeParen */)
|
|
301
|
+
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 1, [
|
|
302
|
+
String.fromCharCode(ch),
|
|
303
|
+
]);
|
|
304
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
305
|
+
isPreviousTermQuantifiable = true;
|
|
306
|
+
continue;
|
|
307
|
+
case 47 /* CharacterCodes.slash */:
|
|
308
|
+
case 124 /* CharacterCodes.bar */:
|
|
309
|
+
return;
|
|
310
|
+
default:
|
|
311
|
+
this.scanSourceCharacter();
|
|
312
|
+
isPreviousTermQuantifiable = true;
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/** Scans the last character of a quantifier and an optional `?`; returns false. */
|
|
318
|
+
scanQuantifier(start, isPreviousTermQuantifiable) {
|
|
319
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
320
|
+
if (this.char() === 63 /* CharacterCodes.question */)
|
|
321
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0; // non-greedy
|
|
322
|
+
if (!isPreviousTermQuantifiable)
|
|
323
|
+
this.error(422 /* Diagnostics.There_is_nothing_available_for_repetition */, start, this.scanner.pos - start, noArgs);
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
scanPatternModifiers(currentFlags) {
|
|
327
|
+
while (this.scanner.pos < this.end) {
|
|
328
|
+
const ch = codePointAt(this.text, this.scanner.pos, this.end);
|
|
329
|
+
if (ch === 65533 /* CharacterCodes.replacementCharacter */ || !isIdentifierPart(ch))
|
|
330
|
+
break;
|
|
331
|
+
const size = charSize(ch);
|
|
332
|
+
const flag = regularExpressionFlag(ch);
|
|
333
|
+
if (flag === 0 /* RegularExpressionFlags.None */)
|
|
334
|
+
this.error(414 /* Diagnostics.Unknown_regular_expression_flag */, this.scanner.pos, size, noArgs);
|
|
335
|
+
else if ((currentFlags & flag) !== 0)
|
|
336
|
+
this.error(415 /* Diagnostics.Duplicate_regular_expression_flag */, this.scanner.pos, size, noArgs);
|
|
337
|
+
else if ((flag & 28 /* RegularExpressionFlags.Modifiers */) === 0)
|
|
338
|
+
this.error(424 /* Diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern */, this.scanner.pos, size, noArgs);
|
|
339
|
+
else {
|
|
340
|
+
currentFlags |= flag;
|
|
341
|
+
this.scanner.checkRegularExpressionFlagAvailability(flag, this.scanner.pos, size);
|
|
342
|
+
}
|
|
343
|
+
this.scanner.pos = (this.scanner.pos + size) | 0;
|
|
344
|
+
}
|
|
345
|
+
return currentFlags;
|
|
346
|
+
}
|
|
347
|
+
// AtomEscape ::= DecimalEscape | CharacterClassEscape | CharacterEscape | 'k<' RegExpIdentifierName '>'
|
|
348
|
+
scanAtomEscape(ch) {
|
|
349
|
+
switch (ch) {
|
|
350
|
+
case 107 /* CharacterCodes.k */:
|
|
351
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
352
|
+
if (this.char() === 60 /* CharacterCodes.lessThan */) {
|
|
353
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
354
|
+
this.scanGroupName(true);
|
|
355
|
+
this.scanExpectedChar(62 /* CharacterCodes.greaterThan */);
|
|
356
|
+
}
|
|
357
|
+
else if (this.anyUnicodeModeOrNonAnnexB || this.namedCaptureGroups) {
|
|
358
|
+
this.error(425 /* Diagnostics.X_k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets */, this.scanner.pos - 2, 2, noArgs);
|
|
359
|
+
}
|
|
360
|
+
return;
|
|
361
|
+
case 113 /* CharacterCodes.q */:
|
|
362
|
+
if (this.unicodeSetsMode) {
|
|
363
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
364
|
+
this.error(426 /* Diagnostics.X_q_is_only_available_inside_character_class */, this.scanner.pos - 2, 2, noArgs);
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
// Regex literals cannot contain line breaks, so a character escape always consumes something.
|
|
370
|
+
if (!this.scanCharacterClassEscape() && !this.scanDecimalEscape())
|
|
371
|
+
this.scanCharacterEscape(true);
|
|
372
|
+
}
|
|
373
|
+
// DecimalEscape ::= [1-9] [0-9]*
|
|
374
|
+
scanDecimalEscape() {
|
|
375
|
+
const ch = this.char();
|
|
376
|
+
if (ch < 49 /* CharacterCodes._1 */ || ch > 57 /* CharacterCodes._9 */)
|
|
377
|
+
return false;
|
|
378
|
+
const start = this.scanner.pos;
|
|
379
|
+
const digits = this.scanDigits();
|
|
380
|
+
this.decimalEscapes.push(new DecimalEscape(start, this.scanner.pos, Number(digits)));
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
// CharacterEscape ::= 'c' ControlLetter | IdentityEscape | (sequences handled by scanEscapeSequence)
|
|
384
|
+
scanCharacterEscape(atomEscape) {
|
|
385
|
+
let ch = this.char();
|
|
386
|
+
switch (ch) {
|
|
387
|
+
case -1 /* CharacterCodes.EOF */:
|
|
388
|
+
this.error(428 /* Diagnostics.Undetermined_character_escape */, this.scanner.pos - 1, 1, noArgs);
|
|
389
|
+
return 92 /* CharacterCodes.backslash */;
|
|
390
|
+
case 99 /* CharacterCodes.c */:
|
|
391
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
392
|
+
ch = this.char();
|
|
393
|
+
if (isASCIILetter(ch)) {
|
|
394
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
395
|
+
return ch & 0x1f;
|
|
396
|
+
}
|
|
397
|
+
if (this.anyUnicodeModeOrNonAnnexB) {
|
|
398
|
+
this.error(427 /* Diagnostics.X_c_must_be_followed_by_an_ASCII_letter */, this.scanner.pos - 2, 2, noArgs);
|
|
399
|
+
}
|
|
400
|
+
else if (atomEscape) {
|
|
401
|
+
this.scanner.pos = (this.scanner.pos - 1) | 0;
|
|
402
|
+
return 92 /* CharacterCodes.backslash */;
|
|
403
|
+
}
|
|
404
|
+
return ch < 0 ? 65533 /* CharacterCodes.replacementCharacter */ : ch;
|
|
405
|
+
case 94 /* CharacterCodes.caret */:
|
|
406
|
+
case 36 /* CharacterCodes.$ */:
|
|
407
|
+
case 47 /* CharacterCodes.slash */:
|
|
408
|
+
case 92 /* CharacterCodes.backslash */:
|
|
409
|
+
case 46 /* CharacterCodes.dot */:
|
|
410
|
+
case 42 /* CharacterCodes.asterisk */:
|
|
411
|
+
case 43 /* CharacterCodes.plus */:
|
|
412
|
+
case 63 /* CharacterCodes.question */:
|
|
413
|
+
case 40 /* CharacterCodes.openParen */:
|
|
414
|
+
case 41 /* CharacterCodes.closeParen */:
|
|
415
|
+
case 91 /* CharacterCodes.openBracket */:
|
|
416
|
+
case 93 /* CharacterCodes.closeBracket */:
|
|
417
|
+
case 123 /* CharacterCodes.openBrace */:
|
|
418
|
+
case 125 /* CharacterCodes.closeBrace */:
|
|
419
|
+
case 124 /* CharacterCodes.bar */:
|
|
420
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
421
|
+
return ch;
|
|
422
|
+
default: {
|
|
423
|
+
this.scanner.pos = (this.scanner.pos - 1) | 0; // include the backslash
|
|
424
|
+
let flags = 4 /* EscapeSequenceScanningFlags.RegularExpression */;
|
|
425
|
+
if (this.annexB)
|
|
426
|
+
flags |= 8 /* EscapeSequenceScanningFlags.AnnexB */;
|
|
427
|
+
if (this.anyUnicodeMode)
|
|
428
|
+
flags |= 16 /* EscapeSequenceScanningFlags.AnyUnicodeMode */;
|
|
429
|
+
if (atomEscape)
|
|
430
|
+
flags |= 32 /* EscapeSequenceScanningFlags.AtomEscape */;
|
|
431
|
+
const value = this.scanner.scanEscapeCodePoint(flags);
|
|
432
|
+
return value === -2 /* EscapeValue.Raw */ ? -2 /* ClassValue.String */ : value;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
scanGroupName(isReference) {
|
|
437
|
+
const scanner = this.scanner;
|
|
438
|
+
scanner.tokenStart = this.scanner.pos | 0;
|
|
439
|
+
scanner.scanIdentifier(0);
|
|
440
|
+
const start = scanner.tokenStart;
|
|
441
|
+
if (this.scanner.pos === start) {
|
|
442
|
+
this.error(429 /* Diagnostics.Expected_a_capturing_group_name */, this.scanner.pos, 0, noArgs);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
const name = scanner.getTokenValue();
|
|
446
|
+
if (isReference) {
|
|
447
|
+
this.groupNameReferences.push(new GroupNameReference(start, this.scanner.pos, name));
|
|
448
|
+
}
|
|
449
|
+
else if (this.namedCapturingGroupsContains(name)) {
|
|
450
|
+
this.error(430 /* Diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other */, start, this.scanner.pos - start, noArgs);
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
if (this.namedCapturingGroups.length > 0)
|
|
454
|
+
this.namedCapturingGroups[this.namedCapturingGroups.length - 1].add(name);
|
|
455
|
+
this.groupSpecifiers.add(name);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
namedCapturingGroupsContains(name) {
|
|
459
|
+
for (const group of this.namedCapturingGroups)
|
|
460
|
+
if (group.has(name))
|
|
461
|
+
return true;
|
|
462
|
+
return false;
|
|
463
|
+
}
|
|
464
|
+
isClassContentExit(ch) {
|
|
465
|
+
return ch === 93 /* CharacterCodes.closeBracket */ || this.scanner.pos >= this.end;
|
|
466
|
+
}
|
|
467
|
+
// ClassRanges ::= '^'? (ClassAtom ('-' ClassAtom)?)*
|
|
468
|
+
// Returns MayContainStrings, which is false for class ranges.
|
|
469
|
+
scanClassRanges() {
|
|
470
|
+
if (this.char() === 94 /* CharacterCodes.caret */)
|
|
471
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
472
|
+
while (this.scanner.pos < this.end) {
|
|
473
|
+
if (this.isClassContentExit(this.char()))
|
|
474
|
+
return false;
|
|
475
|
+
const minStart = this.scanner.pos;
|
|
476
|
+
const min = this.scanClassAtom();
|
|
477
|
+
if (this.char() !== 45 /* CharacterCodes.minus */)
|
|
478
|
+
continue;
|
|
479
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
480
|
+
if (this.isClassContentExit(this.char()))
|
|
481
|
+
return false;
|
|
482
|
+
if (min === -1 /* ClassValue.None */ && this.anyUnicodeModeOrNonAnnexB)
|
|
483
|
+
this.error(431 /* Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class */, minStart, this.scanner.pos - 1 - minStart, noArgs);
|
|
484
|
+
const maxStart = this.scanner.pos;
|
|
485
|
+
const max = this.scanClassAtom();
|
|
486
|
+
if (max === -1 /* ClassValue.None */ && this.anyUnicodeModeOrNonAnnexB) {
|
|
487
|
+
this.error(431 /* Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class */, maxStart, this.scanner.pos - maxStart, noArgs);
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
if (min >= 0 && max >= 0 && min > max)
|
|
491
|
+
this.error(432 /* Diagnostics.Range_out_of_order_in_character_class */, minStart, this.scanner.pos - minStart, noArgs);
|
|
492
|
+
}
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
// ClassSetExpression ::= '^'? (ClassUnion | ClassIntersection | ClassSubtraction)
|
|
496
|
+
// ClassUnion ::= (ClassSetRange | ClassSetOperand)*
|
|
497
|
+
// ClassIntersection ::= ClassSetOperand ('&&' ClassSetOperand)+
|
|
498
|
+
// ClassSubtraction ::= ClassSetOperand ('--' ClassSetOperand)+
|
|
499
|
+
// ClassSetRange ::= ClassSetCharacter '-' ClassSetCharacter
|
|
500
|
+
//
|
|
501
|
+
// mayContainStrings tracks the MayContainStrings static semantics: some operand of a
|
|
502
|
+
// union, every operand of an intersection, or the first operand of a subtraction.
|
|
503
|
+
scanClassSetExpression() {
|
|
504
|
+
let isCharacterComplement = false;
|
|
505
|
+
if (this.char() === 94 /* CharacterCodes.caret */) {
|
|
506
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
507
|
+
isCharacterComplement = true;
|
|
508
|
+
}
|
|
509
|
+
let expressionMayContainStrings = false;
|
|
510
|
+
let ch = this.char();
|
|
511
|
+
if (this.isClassContentExit(ch))
|
|
512
|
+
return this.mayContainStrings;
|
|
513
|
+
let start = this.scanner.pos;
|
|
514
|
+
let operand = -1 /* ClassValue.None */;
|
|
515
|
+
if (this.isDoublePunctuatorOperator()) {
|
|
516
|
+
this.error(435 /* Diagnostics.Expected_a_class_set_operand */, this.scanner.pos, 0, noArgs);
|
|
517
|
+
this.mayContainStrings = false;
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
operand = this.scanClassSetOperand();
|
|
521
|
+
}
|
|
522
|
+
switch (this.char()) {
|
|
523
|
+
case 45 /* CharacterCodes.minus */:
|
|
524
|
+
if (this.scanner.pos + 1 < this.end && this.charAt(this.scanner.pos + 1) === 45 /* CharacterCodes.minus */) {
|
|
525
|
+
if (isCharacterComplement && this.mayContainStrings)
|
|
526
|
+
this.error(433 /* Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class */, start, this.scanner.pos - start, noArgs);
|
|
527
|
+
expressionMayContainStrings = this.mayContainStrings;
|
|
528
|
+
this.scanClassSetSubExpression(3 /* ClassSetExpressionType.ClassSubtraction */);
|
|
529
|
+
this.mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
530
|
+
return this.mayContainStrings;
|
|
531
|
+
}
|
|
532
|
+
break;
|
|
533
|
+
case 38 /* CharacterCodes.ampersand */:
|
|
534
|
+
if (this.scanner.pos + 1 < this.end && this.charAt(this.scanner.pos + 1) === 38 /* CharacterCodes.ampersand */) {
|
|
535
|
+
this.scanClassSetSubExpression(2 /* ClassSetExpressionType.ClassIntersection */);
|
|
536
|
+
if (isCharacterComplement && this.mayContainStrings)
|
|
537
|
+
this.error(433 /* Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class */, start, this.scanner.pos - start, noArgs);
|
|
538
|
+
expressionMayContainStrings = this.mayContainStrings;
|
|
539
|
+
this.mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
540
|
+
return this.mayContainStrings;
|
|
541
|
+
}
|
|
542
|
+
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 1, [
|
|
543
|
+
String.fromCharCode(ch),
|
|
544
|
+
]);
|
|
545
|
+
break;
|
|
546
|
+
default:
|
|
547
|
+
if (isCharacterComplement && this.mayContainStrings)
|
|
548
|
+
this.error(433 /* Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class */, start, this.scanner.pos - start, noArgs);
|
|
549
|
+
expressionMayContainStrings = this.mayContainStrings;
|
|
550
|
+
break;
|
|
551
|
+
}
|
|
552
|
+
while (this.scanner.pos < this.end) {
|
|
553
|
+
ch = this.char();
|
|
554
|
+
if (ch === 45 /* CharacterCodes.minus */) {
|
|
555
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
556
|
+
ch = this.char();
|
|
557
|
+
if (this.isClassContentExit(ch)) {
|
|
558
|
+
this.mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
559
|
+
return this.mayContainStrings;
|
|
560
|
+
}
|
|
561
|
+
if (ch === 45 /* CharacterCodes.minus */) {
|
|
562
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
563
|
+
this.error(434 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos - 2, 2, noArgs);
|
|
564
|
+
start = this.scanner.pos - 2;
|
|
565
|
+
operand = -2 /* ClassValue.String */;
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
if (operand === -1 /* ClassValue.None */)
|
|
569
|
+
this.error(431 /* Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class */, start, this.scanner.pos - 1 - start, noArgs);
|
|
570
|
+
const secondStart = this.scanner.pos;
|
|
571
|
+
const secondOperand = this.scanClassSetOperand();
|
|
572
|
+
if (isCharacterComplement && this.mayContainStrings)
|
|
573
|
+
this.error(433 /* Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class */, secondStart, this.scanner.pos - secondStart, noArgs);
|
|
574
|
+
expressionMayContainStrings = expressionMayContainStrings || this.mayContainStrings;
|
|
575
|
+
if (secondOperand === -1 /* ClassValue.None */) {
|
|
576
|
+
this.error(431 /* Diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class */, secondStart, this.scanner.pos - secondStart, noArgs);
|
|
577
|
+
}
|
|
578
|
+
else if (operand >= 0 && secondOperand >= 0 && operand > secondOperand) {
|
|
579
|
+
this.error(432 /* Diagnostics.Range_out_of_order_in_character_class */, start, this.scanner.pos - start, noArgs);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
else if (ch === 38 /* CharacterCodes.ampersand */) {
|
|
583
|
+
start = this.scanner.pos;
|
|
584
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
585
|
+
if (this.char() === 38 /* CharacterCodes.ampersand */) {
|
|
586
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
587
|
+
this.error(434 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos - 2, 2, noArgs);
|
|
588
|
+
if (this.char() === 38 /* CharacterCodes.ampersand */) {
|
|
589
|
+
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 1, [
|
|
590
|
+
String.fromCharCode(ch),
|
|
591
|
+
]);
|
|
592
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos - 1, 1, [
|
|
597
|
+
String.fromCharCode(ch),
|
|
598
|
+
]);
|
|
599
|
+
}
|
|
600
|
+
operand = this.scanner.pos - start === 1 ? 38 /* CharacterCodes.ampersand */ : -2 /* ClassValue.String */;
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
if (this.isClassContentExit(this.char()))
|
|
604
|
+
break;
|
|
605
|
+
start = this.scanner.pos;
|
|
606
|
+
if (this.isDoublePunctuatorOperator()) {
|
|
607
|
+
this.error(434 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos, 2, noArgs);
|
|
608
|
+
this.scanner.pos = (this.scanner.pos + 2) | 0;
|
|
609
|
+
operand = -2 /* ClassValue.String */;
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
operand = this.scanClassSetOperand();
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
this.mayContainStrings = !isCharacterComplement && expressionMayContainStrings;
|
|
616
|
+
return this.mayContainStrings;
|
|
617
|
+
}
|
|
618
|
+
/** Whether `--` or `&&` starts at the current position. */
|
|
619
|
+
isDoublePunctuatorOperator() {
|
|
620
|
+
if (this.scanner.pos + 1 >= this.end)
|
|
621
|
+
return false;
|
|
622
|
+
const ch = this.text.charCodeAt(this.scanner.pos);
|
|
623
|
+
return ((ch === 45 /* CharacterCodes.minus */ || ch === 38 /* CharacterCodes.ampersand */) &&
|
|
624
|
+
this.text.charCodeAt(this.scanner.pos + 1) === ch);
|
|
625
|
+
}
|
|
626
|
+
scanClassSetSubExpression(expressionType) {
|
|
627
|
+
let expressionMayContainStrings = this.mayContainStrings;
|
|
628
|
+
while (this.scanner.pos < this.end) {
|
|
629
|
+
let ch = this.char();
|
|
630
|
+
if (this.isClassContentExit(ch))
|
|
631
|
+
break;
|
|
632
|
+
if (ch === 45 /* CharacterCodes.minus */) {
|
|
633
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
634
|
+
if (this.char() === 45 /* CharacterCodes.minus */) {
|
|
635
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
636
|
+
if (expressionType !== 3 /* ClassSetExpressionType.ClassSubtraction */)
|
|
637
|
+
this.error(434 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos - 2, 2, noArgs);
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
this.error(434 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos - 1, 1, noArgs);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
else if (ch === 38 /* CharacterCodes.ampersand */) {
|
|
644
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
645
|
+
if (this.char() === 38 /* CharacterCodes.ampersand */) {
|
|
646
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
647
|
+
if (expressionType !== 2 /* ClassSetExpressionType.ClassIntersection */)
|
|
648
|
+
this.error(434 /* Diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead */, this.scanner.pos - 2, 2, noArgs);
|
|
649
|
+
if (this.char() === 38 /* CharacterCodes.ampersand */) {
|
|
650
|
+
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 1, [
|
|
651
|
+
String.fromCharCode(ch),
|
|
652
|
+
]);
|
|
653
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
657
|
+
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos - 1, 1, [
|
|
658
|
+
String.fromCharCode(ch),
|
|
659
|
+
]);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
else if (expressionType === 3 /* ClassSetExpressionType.ClassSubtraction */) {
|
|
663
|
+
this.error(2 /* Diagnostics.X_0_expected */, this.scanner.pos, 0, ['--']);
|
|
664
|
+
}
|
|
665
|
+
else if (expressionType === 2 /* ClassSetExpressionType.ClassIntersection */) {
|
|
666
|
+
this.error(2 /* Diagnostics.X_0_expected */, this.scanner.pos, 0, ['&&']);
|
|
667
|
+
}
|
|
668
|
+
ch = this.char();
|
|
669
|
+
if (this.isClassContentExit(ch)) {
|
|
670
|
+
this.error(435 /* Diagnostics.Expected_a_class_set_operand */, this.scanner.pos, 0, noArgs);
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
this.scanClassSetOperand();
|
|
674
|
+
if (expressionType === 2 /* ClassSetExpressionType.ClassIntersection */)
|
|
675
|
+
expressionMayContainStrings = expressionMayContainStrings && this.mayContainStrings;
|
|
676
|
+
}
|
|
677
|
+
this.mayContainStrings = expressionMayContainStrings;
|
|
678
|
+
}
|
|
679
|
+
// ClassSetOperand ::= '[' ClassSetExpression ']' | '\' CharacterClassEscape | '\q{' ClassStringDisjunctionContents '}' | ClassSetCharacter
|
|
680
|
+
scanClassSetOperand() {
|
|
681
|
+
this.mayContainStrings = false;
|
|
682
|
+
const ch = this.char();
|
|
683
|
+
if (ch === 91 /* CharacterCodes.openBracket */) {
|
|
684
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
685
|
+
this.scanClassSetExpression();
|
|
686
|
+
this.scanExpectedChar(93 /* CharacterCodes.closeBracket */);
|
|
687
|
+
return -1 /* ClassValue.None */;
|
|
688
|
+
}
|
|
689
|
+
if (ch === 92 /* CharacterCodes.backslash */) {
|
|
690
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
691
|
+
if (this.scanCharacterClassEscape())
|
|
692
|
+
return -1 /* ClassValue.None */;
|
|
693
|
+
if (this.char() === 113 /* CharacterCodes.q */) {
|
|
694
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
695
|
+
if (this.char() === 123 /* CharacterCodes.openBrace */) {
|
|
696
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
697
|
+
this.scanClassStringDisjunctionContents();
|
|
698
|
+
this.scanExpectedChar(125 /* CharacterCodes.closeBrace */);
|
|
699
|
+
return -1 /* ClassValue.None */;
|
|
700
|
+
}
|
|
701
|
+
this.error(436 /* Diagnostics.X_q_must_be_followed_by_string_alternatives_enclosed_in_braces */, this.scanner.pos - 2, 2, noArgs);
|
|
702
|
+
return 113 /* CharacterCodes.q */;
|
|
703
|
+
}
|
|
704
|
+
this.scanner.pos = (this.scanner.pos - 1) | 0;
|
|
705
|
+
}
|
|
706
|
+
return this.scanClassSetCharacter();
|
|
707
|
+
}
|
|
708
|
+
// ClassStringDisjunctionContents ::= ClassSetCharacter* ('|' ClassSetCharacter*)*
|
|
709
|
+
scanClassStringDisjunctionContents() {
|
|
710
|
+
let characterCount = 0;
|
|
711
|
+
while (this.scanner.pos < this.end) {
|
|
712
|
+
const ch = this.char();
|
|
713
|
+
if (ch === 125 /* CharacterCodes.closeBrace */) {
|
|
714
|
+
if (characterCount !== 1)
|
|
715
|
+
this.mayContainStrings = true;
|
|
716
|
+
return this.mayContainStrings;
|
|
717
|
+
}
|
|
718
|
+
if (ch === 124 /* CharacterCodes.bar */) {
|
|
719
|
+
if (characterCount !== 1)
|
|
720
|
+
this.mayContainStrings = true;
|
|
721
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
722
|
+
characterCount = 0;
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
this.scanClassSetCharacter();
|
|
726
|
+
characterCount++;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return this.mayContainStrings;
|
|
730
|
+
}
|
|
731
|
+
// ClassSetCharacter ::= SourceCharacter -- ClassSetSyntaxCharacter -- ClassSetReservedDoublePunctuator
|
|
732
|
+
// | '\' (CharacterEscape | ClassSetReservedPunctuator | 'b')
|
|
733
|
+
scanClassSetCharacter() {
|
|
734
|
+
const ch = this.char();
|
|
735
|
+
if (ch === 92 /* CharacterCodes.backslash */) {
|
|
736
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
737
|
+
const inner = this.char();
|
|
738
|
+
switch (inner) {
|
|
739
|
+
case 98 /* CharacterCodes.b */:
|
|
740
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
741
|
+
return 8 /* CharacterCodes.backspace */;
|
|
742
|
+
case 38 /* CharacterCodes.ampersand */:
|
|
743
|
+
case 45 /* CharacterCodes.minus */:
|
|
744
|
+
case 33 /* CharacterCodes.exclamation */:
|
|
745
|
+
case 35 /* CharacterCodes.hash */:
|
|
746
|
+
case 37 /* CharacterCodes.percent */:
|
|
747
|
+
case 44 /* CharacterCodes.comma */:
|
|
748
|
+
case 58 /* CharacterCodes.colon */:
|
|
749
|
+
case 59 /* CharacterCodes.semicolon */:
|
|
750
|
+
case 60 /* CharacterCodes.lessThan */:
|
|
751
|
+
case 61 /* CharacterCodes.equals */:
|
|
752
|
+
case 62 /* CharacterCodes.greaterThan */:
|
|
753
|
+
case 64 /* CharacterCodes.at */:
|
|
754
|
+
case 96 /* CharacterCodes.backtick */:
|
|
755
|
+
case 126 /* CharacterCodes.tilde */:
|
|
756
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
757
|
+
return inner;
|
|
758
|
+
default:
|
|
759
|
+
return this.scanCharacterEscape(false);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
if (this.scanner.pos + 1 < this.end && ch === this.charAt(this.scanner.pos + 1)) {
|
|
763
|
+
switch (ch) {
|
|
764
|
+
case 38 /* CharacterCodes.ampersand */:
|
|
765
|
+
case 33 /* CharacterCodes.exclamation */:
|
|
766
|
+
case 35 /* CharacterCodes.hash */:
|
|
767
|
+
case 37 /* CharacterCodes.percent */:
|
|
768
|
+
case 42 /* CharacterCodes.asterisk */:
|
|
769
|
+
case 43 /* CharacterCodes.plus */:
|
|
770
|
+
case 44 /* CharacterCodes.comma */:
|
|
771
|
+
case 46 /* CharacterCodes.dot */:
|
|
772
|
+
case 58 /* CharacterCodes.colon */:
|
|
773
|
+
case 59 /* CharacterCodes.semicolon */:
|
|
774
|
+
case 60 /* CharacterCodes.lessThan */:
|
|
775
|
+
case 61 /* CharacterCodes.equals */:
|
|
776
|
+
case 62 /* CharacterCodes.greaterThan */:
|
|
777
|
+
case 63 /* CharacterCodes.question */:
|
|
778
|
+
case 64 /* CharacterCodes.at */:
|
|
779
|
+
case 96 /* CharacterCodes.backtick */:
|
|
780
|
+
case 126 /* CharacterCodes.tilde */:
|
|
781
|
+
this.error(437 /* Diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 2, noArgs);
|
|
782
|
+
this.scanner.pos = (this.scanner.pos + 2) | 0;
|
|
783
|
+
return -2 /* ClassValue.String */;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
switch (ch) {
|
|
787
|
+
case 47 /* CharacterCodes.slash */:
|
|
788
|
+
case 40 /* CharacterCodes.openParen */:
|
|
789
|
+
case 41 /* CharacterCodes.closeParen */:
|
|
790
|
+
case 91 /* CharacterCodes.openBracket */:
|
|
791
|
+
case 93 /* CharacterCodes.closeBracket */:
|
|
792
|
+
case 123 /* CharacterCodes.openBrace */:
|
|
793
|
+
case 125 /* CharacterCodes.closeBrace */:
|
|
794
|
+
case 45 /* CharacterCodes.minus */:
|
|
795
|
+
case 124 /* CharacterCodes.bar */:
|
|
796
|
+
this.error(423 /* Diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash */, this.scanner.pos, 1, [
|
|
797
|
+
String.fromCharCode(ch),
|
|
798
|
+
]);
|
|
799
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
800
|
+
return ch;
|
|
801
|
+
}
|
|
802
|
+
return this.scanSourceCharacter();
|
|
803
|
+
}
|
|
804
|
+
// ClassAtom ::= SourceCharacter but not '\' or ']' | '\' ClassEscape
|
|
805
|
+
// ClassEscape ::= 'b' | '-' | CharacterClassEscape | CharacterEscape
|
|
806
|
+
scanClassAtom() {
|
|
807
|
+
if (this.char() !== 92 /* CharacterCodes.backslash */)
|
|
808
|
+
return this.scanSourceCharacter();
|
|
809
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
810
|
+
const ch = this.char();
|
|
811
|
+
if (ch === 98 /* CharacterCodes.b */) {
|
|
812
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
813
|
+
return 8 /* CharacterCodes.backspace */;
|
|
814
|
+
}
|
|
815
|
+
if (ch === 45 /* CharacterCodes.minus */) {
|
|
816
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
817
|
+
return 45 /* CharacterCodes.minus */;
|
|
818
|
+
}
|
|
819
|
+
if (this.scanCharacterClassEscape())
|
|
820
|
+
return -1 /* ClassValue.None */;
|
|
821
|
+
return this.scanCharacterEscape(false);
|
|
822
|
+
}
|
|
823
|
+
// CharacterClassEscape ::= 'd' | 'D' | 's' | 'S' | 'w' | 'W'
|
|
824
|
+
// | [+AnyUnicodeMode] ('P' | 'p') '{' UnicodePropertyValueExpression '}'
|
|
825
|
+
scanCharacterClassEscape() {
|
|
826
|
+
const start = this.scanner.pos - 1;
|
|
827
|
+
const ch = this.char();
|
|
828
|
+
switch (ch) {
|
|
829
|
+
case 100 /* CharacterCodes.d */:
|
|
830
|
+
case 68 /* CharacterCodes.D */:
|
|
831
|
+
case 115 /* CharacterCodes.s */:
|
|
832
|
+
case 83 /* CharacterCodes.S */:
|
|
833
|
+
case 119 /* CharacterCodes.w */:
|
|
834
|
+
case 87 /* CharacterCodes.W */:
|
|
835
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
836
|
+
return true;
|
|
837
|
+
case 80 /* CharacterCodes.P */:
|
|
838
|
+
case 112 /* CharacterCodes.p */:
|
|
839
|
+
break;
|
|
840
|
+
default:
|
|
841
|
+
return false;
|
|
842
|
+
}
|
|
843
|
+
const isCharacterComplement = ch === 80 /* CharacterCodes.P */;
|
|
844
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
845
|
+
if (this.char() !== 123 /* CharacterCodes.openBrace */) {
|
|
846
|
+
if (!this.anyUnicodeModeOrNonAnnexB) {
|
|
847
|
+
this.scanner.pos = (this.scanner.pos - 1) | 0;
|
|
848
|
+
return false;
|
|
849
|
+
}
|
|
850
|
+
this.error(446 /* Diagnostics.X_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces */, this.scanner.pos - 2, 2, [String.fromCharCode(ch)]);
|
|
851
|
+
return true;
|
|
852
|
+
}
|
|
853
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
854
|
+
const nameOrValueStart = this.scanner.pos;
|
|
855
|
+
const nameOrValue = this.scanWordCharacters();
|
|
856
|
+
if (this.char() === 61 /* CharacterCodes.equals */) {
|
|
857
|
+
const propertyName = nonBinaryUnicodeProperties.get(nameOrValue) ?? '';
|
|
858
|
+
if (this.scanner.pos === nameOrValueStart) {
|
|
859
|
+
this.error(438 /* Diagnostics.Expected_a_Unicode_property_name */, this.scanner.pos, 0, noArgs);
|
|
860
|
+
}
|
|
861
|
+
else if (propertyName === '') {
|
|
862
|
+
this.error(439 /* Diagnostics.Unknown_Unicode_property_name */, nameOrValueStart, this.scanner.pos - nameOrValueStart, noArgs);
|
|
863
|
+
const suggestion = getSpellingSuggestion(nameOrValue, mapKeys(nonBinaryUnicodeProperties));
|
|
864
|
+
if (suggestion !== '')
|
|
865
|
+
this.error(303 /* Diagnostics.Did_you_mean_0 */, nameOrValueStart, this.scanner.pos - nameOrValueStart, [suggestion]);
|
|
866
|
+
}
|
|
867
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
868
|
+
const valueStart = this.scanner.pos;
|
|
869
|
+
const value = this.scanWordCharacters();
|
|
870
|
+
if (this.scanner.pos === valueStart) {
|
|
871
|
+
this.error(440 /* Diagnostics.Expected_a_Unicode_property_value */, this.scanner.pos, 0, noArgs);
|
|
872
|
+
}
|
|
873
|
+
else if (propertyName !== '') {
|
|
874
|
+
const values = valuesOfNonBinaryUnicodeProperty(propertyName);
|
|
875
|
+
if (!values.has(value)) {
|
|
876
|
+
this.error(441 /* Diagnostics.Unknown_Unicode_property_value */, valueStart, this.scanner.pos - valueStart, noArgs);
|
|
877
|
+
const suggestion = getSpellingSuggestion(value, setToArray(values));
|
|
878
|
+
if (suggestion !== '')
|
|
879
|
+
this.error(303 /* Diagnostics.Did_you_mean_0 */, valueStart, this.scanner.pos - valueStart, [suggestion]);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
else if (this.scanner.pos === nameOrValueStart) {
|
|
884
|
+
this.error(442 /* Diagnostics.Expected_a_Unicode_property_name_or_value */, this.scanner.pos, 0, noArgs);
|
|
885
|
+
}
|
|
886
|
+
else if (binaryUnicodePropertiesOfStrings.has(nameOrValue)) {
|
|
887
|
+
if (!this.unicodeSetsMode)
|
|
888
|
+
this.error(443 /* Diagnostics.Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set */, nameOrValueStart, this.scanner.pos - nameOrValueStart, noArgs);
|
|
889
|
+
else if (isCharacterComplement)
|
|
890
|
+
this.error(433 /* Diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class */, nameOrValueStart, this.scanner.pos - nameOrValueStart, noArgs);
|
|
891
|
+
else
|
|
892
|
+
this.mayContainStrings = true;
|
|
893
|
+
}
|
|
894
|
+
else if (!generalCategoryValues.has(nameOrValue) && !binaryUnicodeProperties.has(nameOrValue)) {
|
|
895
|
+
this.error(444 /* Diagnostics.Unknown_Unicode_property_name_or_value */, nameOrValueStart, this.scanner.pos - nameOrValueStart, noArgs);
|
|
896
|
+
const candidates = setToArray(generalCategoryValues);
|
|
897
|
+
for (const name of binaryUnicodeProperties)
|
|
898
|
+
candidates.push(name);
|
|
899
|
+
for (const name of binaryUnicodePropertiesOfStrings)
|
|
900
|
+
candidates.push(name);
|
|
901
|
+
const suggestion = getSpellingSuggestion(nameOrValue, candidates);
|
|
902
|
+
if (suggestion !== '')
|
|
903
|
+
this.error(303 /* Diagnostics.Did_you_mean_0 */, nameOrValueStart, this.scanner.pos - nameOrValueStart, [suggestion]);
|
|
904
|
+
}
|
|
905
|
+
this.scanExpectedChar(125 /* CharacterCodes.closeBrace */);
|
|
906
|
+
if (!this.anyUnicodeMode)
|
|
907
|
+
this.error(445 /* Diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set */, start, this.scanner.pos - start, noArgs);
|
|
908
|
+
return true;
|
|
909
|
+
}
|
|
910
|
+
scanWordCharacters() {
|
|
911
|
+
const start = this.scanner.pos;
|
|
912
|
+
while (this.scanner.pos < this.end && isWordCharacter(this.char()))
|
|
913
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
914
|
+
return this.text.substring(start, this.scanner.pos);
|
|
915
|
+
}
|
|
916
|
+
/** One code point in Unicode modes, otherwise one UTF-16 code unit. */
|
|
917
|
+
scanSourceCharacter() {
|
|
918
|
+
if (this.scanner.pos >= this.end)
|
|
919
|
+
return -1 /* ClassValue.None */;
|
|
920
|
+
if (!this.anyUnicodeMode) {
|
|
921
|
+
const ch = this.scanner.chars[this.scanner.pos];
|
|
922
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
923
|
+
return ch;
|
|
924
|
+
}
|
|
925
|
+
const ch = this.scanner.codePointAt(this.scanner.pos, this.end);
|
|
926
|
+
this.scanner.pos = (this.scanner.pos + charSize(ch)) | 0;
|
|
927
|
+
// Like TypeScript 7, treat U+FFFD as an undecodable character.
|
|
928
|
+
return ch === 65533 /* CharacterCodes.replacementCharacter */ ? -1 /* ClassValue.None */ : ch;
|
|
929
|
+
}
|
|
930
|
+
scanExpectedChar(ch) {
|
|
931
|
+
if (this.char() === ch)
|
|
932
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
933
|
+
else
|
|
934
|
+
this.error(2 /* Diagnostics.X_0_expected */, this.scanner.pos, 0, [String.fromCharCode(ch)]);
|
|
935
|
+
}
|
|
936
|
+
scanDigits() {
|
|
937
|
+
const start = this.scanner.pos;
|
|
938
|
+
while (this.scanner.pos < this.end && isDigit(this.char()))
|
|
939
|
+
this.scanner.pos = (this.scanner.pos + 1) | 0;
|
|
940
|
+
return this.text.substring(start, this.scanner.pos);
|
|
941
|
+
}
|
|
942
|
+
}
|