Skip to content

Commit

Permalink
feat: update js engine and grammars (#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
slevithan authored Dec 19, 2024
1 parent c489859 commit 5a26f77
Show file tree
Hide file tree
Showing 8 changed files with 2,613 additions and 521 deletions.
60 changes: 30 additions & 30 deletions docs/references/engine-js-compat.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Compatibility reference of all built-in grammars with the [JavaScript RegExp engine](/guide/regex-engines#javascript-regexp-engine-experimental).

> Generated on Monday, December 16, 2024
> Generated on Thursday, December 19, 2024
>
> Version `1.24.2`
>
Expand All @@ -13,8 +13,8 @@ Compatibility reference of all built-in grammars with the [JavaScript RegExp eng
| | Count |
| :-------------- | --------------------------: |
| Total Languages | 218 |
| Supported | [199](#supported-languages) |
| Mismatched | [13](#mismatched-languages) |
| Supported | [206](#supported-languages) |
| Mismatched | [6](#mismatched-languages) |
| Unsupported | [6](#unsupported-languages) |

## Supported Languages
Expand All @@ -39,6 +39,7 @@ In some edge cases, it's not guaranteed that the highlighting will be 100% the s
| ballerina | βœ… OK | 230 | - | |
| bash | βœ… OK | 148 | - | |
| bat | βœ… OK | 58 | - | |
| beancount | βœ… OK | 39 | - | |
| berry | βœ… OK | 18 | - | |
| bibtex | βœ… OK | 19 | - | |
| bicep | βœ… OK | 27 | - | |
Expand Down Expand Up @@ -74,7 +75,7 @@ In some edge cases, it's not guaranteed that the highlighting will be 100% the s
| elixir | βœ… OK | 708 | - | |
| elm | βœ… OK | 244 | - | |
| emacs-lisp | βœ… OK | 153 | - | 22 |
| erb | βœ… OK | 1312 | - | |
| erb | βœ… OK | 1786 | - | |
| erlang | βœ… OK | 147 | - | |
| fennel | βœ… OK | 31 | - | |
| fish | βœ… OK | 25 | - | |
Expand All @@ -83,8 +84,8 @@ In some edge cases, it's not guaranteed that the highlighting will be 100% the s
| fortran-free-form | βœ… OK | 328 | - | |
| fsharp | βœ… OK | 239 | - | |
| fsl | βœ… OK | 30 | - | |
| gdresource | βœ… OK | 159 | - | |
| gdscript | βœ… OK | 95 | - | |
| gdresource | βœ… OK | 158 | - | |
| gdscript | βœ… OK | 94 | - | |
| gdshader | βœ… OK | 39 | - | |
| genie | βœ… OK | 20 | - | |
| gherkin | βœ… OK | 19 | - | |
Expand All @@ -98,6 +99,7 @@ In some edge cases, it's not guaranteed that the highlighting will be 100% the s
| groovy | βœ… OK | 133 | - | |
| haml | βœ… OK | 562 | - | |
| handlebars | βœ… OK | 699 | - | |
| haskell | βœ… OK | 157 | - | |
| haxe | βœ… OK | 174 | - | |
| hcl | βœ… OK | 67 | - | |
| hjson | βœ… OK | 57 | - | |
Expand All @@ -120,6 +122,7 @@ In some edge cases, it's not guaranteed that the highlighting will be 100% the s
| jssm | βœ… OK | 30 | - | |
| jsx | βœ… OK | 376 | - | |
| julia | βœ… OK | 1168 | - | |
| kotlin | βœ… OK | 58 | - | |
| latex | βœ… OK | 283 | - | |
| lean | βœ… OK | 32 | - | |
| less | βœ… OK | 280 | - | |
Expand All @@ -131,6 +134,7 @@ In some edge cases, it's not guaranteed that the highlighting will be 100% the s
| make | βœ… OK | 51 | - | |
| marko | βœ… OK | 926 | - | |
| matlab | βœ… OK | 88 | - | |
| mdc | βœ… OK | 783 | - | |
| mdx | βœ… OK | 197 | - | |
| mermaid | βœ… OK | 134 | - | |
| mipsasm | βœ… OK | 17 | - | |
Expand All @@ -146,26 +150,29 @@ In some edge cases, it's not guaranteed that the highlighting will be 100% the s
| ocaml | βœ… OK | 178 | - | |
| pascal | βœ… OK | 23 | - | |
| perl | βœ… OK | 941 | - | |
| php | βœ… OK | 1131 | - | |
| plsql | βœ… OK | 45 | - | |
| postcss | βœ… OK | 49 | - | |
| powerquery | βœ… OK | 30 | - | |
| powershell | βœ… OK | 88 | - | |
| prisma | βœ… OK | 26 | - | |
| prisma | βœ… OK | 28 | - | |
| prolog | βœ… OK | 26 | - | |
| proto | βœ… OK | 33 | - | |
| pug | βœ… OK | 686 | - | |
| puppet | βœ… OK | 61 | - | |
| python | βœ… OK | 218 | - | |
| qml | βœ… OK | 408 | - | |
| qmldir | βœ… OK | 7 | - | |
| qss | βœ… OK | 31 | - | |
| r | βœ… OK | 71 | - | |
| racket | βœ… OK | 69 | - | 8 |
| racket | βœ… OK | 69 | - | |
| raku | βœ… OK | 52 | - | |
| reg | βœ… OK | 9 | - | |
| regexp | βœ… OK | 34 | - | |
| rel | βœ… OK | 17 | - | |
| riscv | βœ… OK | 36 | - | |
| ruby | βœ… OK | 1307 | - | |
| rst | βœ… OK | 2031 | - | |
| ruby | βœ… OK | 1781 | - | |
| rust | βœ… OK | 89 | - | |
| sas | βœ… OK | 101 | - | |
| sass | βœ… OK | 69 | - | |
Expand Down Expand Up @@ -199,7 +206,7 @@ In some edge cases, it's not guaranteed that the highlighting will be 100% the s
| tsv | βœ… OK | 1 | - | |
| tsx | βœ… OK | 376 | - | |
| turtle | βœ… OK | 15 | - | |
| twig | βœ… OK | 1984 | - | |
| twig | βœ… OK | 2426 | - | |
| typescript | βœ… OK | 363 | - | |
| typespec | βœ… OK | 80 | - | |
| typst | βœ… OK | 78 | - | |
Expand Down Expand Up @@ -235,31 +242,24 @@ In some edge cases, it's not guaranteed that the highlighting will be 100% the s

Languages that do not throw with the JavaScript RegExp engine, but will produce different results than the WASM engine. Please use with caution.

| Language | Highlight Match | Patterns Parsable | Patterns Failed | Diff |
| --------- | :----------------------------------------------------------------------------- | ----------------: | --------------: | ---: |
| apex | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=apex) | 187 | - | 236 |
| beancount | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=beancount) | 39 | - | 171 |
| cpp | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=cpp) | 512 | - | 8 |
| haskell | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=haskell) | 157 | - | 39 |
| kotlin | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=kotlin) | 58 | - | 1953 |
| kusto | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=kusto) | 60 | - | 40 |
| markdown | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=markdown) | 118 | - | 915 |
| mdc | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=mdc) | 783 | - | 702 |
| nginx | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=nginx) | 378 | - | 4 |
| php | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=php) | 1131 | - | 605 |
| po | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=po) | 23 | - | 423 |
| pug | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=pug) | 686 | - | 164 |
| rst | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=rst) | 1857 | - | 62 |
| Language | Highlight Match | Patterns Parsable | Patterns Failed | Diff |
| -------- | :---------------------------------------------------------------------------- | ----------------: | --------------: | ---: |
| apex | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=apex) | 187 | - | 33 |
| cpp | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=cpp) | 512 | - | 8 |
| kusto | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=kusto) | 60 | - | 40 |
| markdown | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=markdown) | 118 | - | 100 |
| nginx | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=nginx) | 378 | - | 122 |
| po | [🚧 Mismatch](https://textmate-grammars-themes.netlify.app/?grammar=po) | 23 | - | 114 |

## Unsupported Languages

Languages that throw with the JavaScript RegExp engine, either because they contain syntax we can't polyfill yet or because the grammar contains an invalid Oniguruma regex (that would also fail when using the WASM engine, but silently). You can try these languages with the `forgiving` option to skip errors, but usually it's best to use the Oniguruma engine instead.
Languages that throw with the JavaScript RegExp engine, either because they contain syntax we can't polyfill yet or because the grammar contains an invalid Oniguruma regex (that would also fail when using the WASM engine, but silently). You can try these languages with the `forgiving` option to skip errors.

| Language | Highlight Match | Patterns Parsable | Patterns Failed | Diff |
| ---------- | :-------------- | ----------------: | --------------: | ---: |
| ada | βœ… OK | 201 | 1 | |
| hack | ❌ Error | 947 | 1 | 114 |
| purescript | ❌ Error | 72 | 1 | 42 |
| csharp | ❌ Error | 306 | 3 | 204 |
| swift | ❌ Error | 326 | 3 | 40 |
| razor | ❌ Error | 952 | 5 | 22 |
| purescript | ❌ Error | 72 | 1 | |
| csharp | ❌ Error | 306 | 3 | 148 |
| swift | ❌ Error | 326 | 3 | 8 |
| razor | ❌ Error | 952 | 5 | 14 |
8 changes: 5 additions & 3 deletions packages/engine-javascript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ export function defaultJavaScriptRegexConstructor(pattern: string, options?: Oni
global: true,
hasIndices: true,
rules: {
// Needed since TextMate grammars merge backrefs across patterns
allowOrphanBackrefs: true,
// Dropping unhandled `\G` anchors without erroring allows more grammars to pass but also
// allows some false positive and negative matches. It's mostly because this is true that
// the JS engine is marked as experimental
// Removing `\G` anchors in cases when they're not supported for emulation allows
// supporting more grammars, but also allows some mismatches
allowUnhandledGAnchors: true,
// Improves search performance for generated regexes
asciiWordBoundaries: true,
// Follow `vscode-oniguruma` which enables this Oniguruma option by default
captureGroup: true,
},
...options,
},
Expand Down
Loading

0 comments on commit 5a26f77

Please sign in to comment.