diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index 41176dee..c5a31279 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -9,14 +9,14 @@ Regenerate it with `composer compatibility` after changing an engine, the transl - **First PCRE difference** is the first line where the PCRE engine's tokens differ from vscode-textmate's. - Neighbouring tokens with the same scopes are merged before comparing, and the newline at the end of each line is not compared. Neither changes the rendered output. -Generated with PHP 8.4.27, PCRE2 10.42 and Oniguruma 6.9.9. +Generated with PHP 8.4.27, PCRE2 10.42 and Oniguruma 6.9.8. ## Summary | Engine | Grammars identical | Matching tokens | | --- | ---: | ---: | -| Oniguruma | 113 of 227 | 93.1% (195150 of 209677) | -| PCRE | 163 of 227 | 96.2% (201734 of 209677) | +| Oniguruma | 152 of 227 | 97.1% (203680 of 209677) | +| PCRE | 219 of 227 | 99.9% (209370 of 209677) | ## Grammars @@ -27,39 +27,39 @@ Generated with PHP 8.4.27, PCRE2 10.42 and Oniguruma 6.9.9. | ada | [ada.sample](tests/Fixtures/samples/ada.sample) | 75.3% | 1790 | 98.2% | 100.0% | ✅ Identical | | angular-html | [angular-html.sample](tests/Fixtures/samples/angular-html.sample) | 33.3% | 93 | 100.0% | 100.0% | ✅ Identical | | angular-ts | [angular-ts.sample](tests/Fixtures/samples/angular-ts.sample) | 54.2% | 2133 | 100.0% | 100.0% | ✅ Identical | -| antlers | [antlers.sample](tests/Fixtures/samples/antlers.sample) | 83.0% | 891 | 98.3% | 98.3% | [Line 10](tests/Fixtures/samples/antlers.sample#L10) | -| apache | [apache.sample](tests/Fixtures/samples/apache.sample) | 60.0% | 497 | 91.5% | 100.0% | ✅ Identical | +| antlers | [antlers.sample](tests/Fixtures/samples/antlers.sample) | 88.7% | 891 | 100.0% | 100.0% | ✅ Identical | +| apache | [apache.sample](tests/Fixtures/samples/apache.sample) | 60.0% | 497 | 97.0% | 100.0% | ✅ Identical | | apex | [apex.sample](tests/Fixtures/samples/apex.sample) | 59.4% | 1946 | 80.8% | 100.0% | ✅ Identical | -| apl | [apl.sample](tests/Fixtures/samples/apl.sample) | 61.8% | 1355 | 98.4% | 99.3% | [Line 110](tests/Fixtures/samples/apl.sample#L110) | -| applescript | [applescript.sample](tests/Fixtures/samples/applescript.sample) | 52.9% | 877 | 97.8% | 100.0% | ✅ Identical | -| ara | [ara.sample](tests/Fixtures/samples/ara.sample) | 84.5% | 1053 | 72.4% | 72.4% | [Line 49](tests/Fixtures/samples/ara.sample#L49) | -| asciidoc | [asciidoc.sample](tests/Fixtures/samples/asciidoc.sample) | 13.4% | 715 | 93.1% | 94.8% | [Line 204](tests/Fixtures/samples/asciidoc.sample#L204) | -| asm | [asm.sample](tests/Fixtures/samples/asm.sample) | 29.1% | 932 | 99.7% | 99.7% | [Line 15](tests/Fixtures/samples/asm.sample#L15) | -| astro | [astro.sample](tests/Fixtures/samples/astro.sample) | 58.3% | 1149 | 70.8% | 70.8% | [Line 85](tests/Fixtures/samples/astro.sample#L85) | +| apl | [apl.sample](tests/Fixtures/samples/apl.sample) | 61.8% | 1355 | 100.0% | 100.0% | ✅ Identical | +| applescript | [applescript.sample](tests/Fixtures/samples/applescript.sample) | 52.9% | 877 | 98.3% | 100.0% | ✅ Identical | +| ara | [ara.sample](tests/Fixtures/samples/ara.sample) | 81.0% | 1053 | 100.0% | 100.0% | ✅ Identical | +| asciidoc | [asciidoc.sample](tests/Fixtures/samples/asciidoc.sample) | 13.3% | 715 | 98.3% | 100.0% | ✅ Identical | +| asm | [asm.sample](tests/Fixtures/samples/asm.sample) | 27.2% | 932 | 100.0% | 100.0% | ✅ Identical | +| astro | [astro.sample](tests/Fixtures/samples/astro.sample) | 74.0% | 1149 | 100.0% | 100.0% | ✅ Identical | | awk | [awk.sample](tests/Fixtures/samples/awk.sample) | 37.2% | 77 | 100.0% | 100.0% | ✅ Identical | | ballerina | [ballerina.sample](tests/Fixtures/samples/ballerina.sample) | 39.9% | 1747 | 100.0% | 100.0% | ✅ Identical | -| bat | [bat.sample](tests/Fixtures/samples/bat.sample) | 96.2% | 499 | 99.8% | 100.0% | ✅ Identical | -| beancount | [beancount.sample](tests/Fixtures/samples/beancount.sample) | 94.5% | 619 | 98.4% | 100.0% | ✅ Identical | +| bat | [bat.sample](tests/Fixtures/samples/bat.sample) | 96.2% | 499 | 100.0% | 100.0% | ✅ Identical | +| beancount | [beancount.sample](tests/Fixtures/samples/beancount.sample) | 94.5% | 619 | 100.0% | 100.0% | ✅ Identical | | berry | [berry.sample](tests/Fixtures/samples/berry.sample) | 45.0% | 289 | 100.0% | 100.0% | ✅ Identical | | bibtex | [bibtex.sample](tests/Fixtures/samples/bibtex.sample) | 42.9% | 124 | 100.0% | 100.0% | ✅ Identical | -| blade | [blade.sample](tests/Fixtures/samples/blade.sample) | 25.1% | 1928 | 97.4% | 99.7% | [Line 54](tests/Fixtures/samples/blade.sample#L54) | -| bsl | [bsl.sample](tests/Fixtures/samples/bsl.sample) | 31.1% | 387 | 71.1% | 100.0% | ✅ Identical | -| c | [c.sample](tests/Fixtures/samples/c.sample) | 90.2% | 3078 | 97.7% | 100.0% | ✅ Identical | -| cadence | [cadence.sample](tests/Fixtures/samples/cadence.sample) | 78.0% | 1367 | 91.1% | 91.4% | [Line 10](tests/Fixtures/samples/cadence.sample#L10) | +| blade | [blade.sample](tests/Fixtures/samples/blade.sample) | 25.1% | 1928 | 97.6% | 100.0% | ✅ Identical | +| bsl | [bsl.sample](tests/Fixtures/samples/bsl.sample) | 31.1% | 387 | 100.0% | 100.0% | ✅ Identical | +| c | [c.sample](tests/Fixtures/samples/c.sample) | 90.2% | 3078 | 100.0% | 100.0% | ✅ Identical | +| cadence | [cadence.sample](tests/Fixtures/samples/cadence.sample) | 74.6% | 1367 | 99.8% | 100.0% | ✅ Identical | | cairo | [cairo.sample](tests/Fixtures/samples/cairo.sample) | 100.0% | 338 | 100.0% | 100.0% | ✅ Identical | -| clarity | [clarity.sample](tests/Fixtures/samples/clarity.sample) | 37.7% | 258 | 76.4% | 76.4% | [Line 1](tests/Fixtures/samples/clarity.sample#L1) | +| clarity | [clarity.sample](tests/Fixtures/samples/clarity.sample) | 38.0% | 258 | 100.0% | 100.0% | ✅ Identical | | clojure | [clojure.sample](tests/Fixtures/samples/clojure.sample) | 34.1% | 153 | 100.0% | 100.0% | ✅ Identical | | cmake | [cmake.sample](tests/Fixtures/samples/cmake.sample) | 79.3% | 377 | 100.0% | 100.0% | ✅ Identical | | cobol | [cobol.sample](tests/Fixtures/samples/cobol.sample) | 44.1% | 1370 | 99.1% | 100.0% | ✅ Identical | | codeowners | [codeowners.sample](tests/Fixtures/samples/codeowners.sample) | 100.0% | 15 | 100.0% | 100.0% | ✅ Identical | | codeql | [codeql.sample](tests/Fixtures/samples/codeql.sample) | 44.4% | 726 | 100.0% | 100.0% | ✅ Identical | -| coffee | [coffee.sample](tests/Fixtures/samples/coffee.sample) | 73.4% | 1242 | 96.8% | 96.8% | [Line 111](tests/Fixtures/samples/coffee.sample#L111) | +| coffee | [coffee.sample](tests/Fixtures/samples/coffee.sample) | 72.0% | 1242 | 99.9% | 99.9% | [Line 148](tests/Fixtures/samples/coffee.sample#L148) | | common-lisp | [common-lisp.sample](tests/Fixtures/samples/common-lisp.sample) | 48.4% | 199 | 100.0% | 100.0% | ✅ Identical | | coq | [coq.sample](tests/Fixtures/samples/coq.sample) | 56.2% | 193 | 100.0% | 100.0% | ✅ Identical | -| cpp | [cpp.sample](tests/Fixtures/samples/cpp.sample) | 67.1% | 7347 | 97.1% | 98.3% | [Line 39](tests/Fixtures/samples/cpp.sample#L39) | +| cpp | [cpp.sample](tests/Fixtures/samples/cpp.sample) | 70.4% | 7347 | 98.7% | 98.3% | [Line 39](tests/Fixtures/samples/cpp.sample#L39) | | crystal | [crystal.sample](tests/Fixtures/samples/crystal.sample) | 47.6% | 1199 | 100.0% | 100.0% | ✅ Identical | -| csharp | [csharp.sample](tests/Fixtures/samples/csharp.sample) | 94.6% | 4482 | 81.2% | 99.9% | [Line 94](tests/Fixtures/samples/csharp.sample#L94) | -| css | [css.sample](tests/Fixtures/samples/css.sample) | 95.5% | 1605 | 97.1% | 97.3% | [Line 2](tests/Fixtures/samples/css.sample#L2) | +| csharp | [csharp.sample](tests/Fixtures/samples/csharp.sample) | 94.6% | 4482 | 82.6% | 100.0% | ✅ Identical | +| css | [css.sample](tests/Fixtures/samples/css.sample) | 95.5% | 1605 | 99.8% | 100.0% | ✅ Identical | | csv | [csv.sample](tests/Fixtures/samples/csv.sample) | 100.0% | 25 | 100.0% | 100.0% | ✅ Identical | | cue | [cue.sample](tests/Fixtures/samples/cue.sample) | 66.9% | 1298 | 99.9% | 100.0% | ✅ Identical | | cypher | [cypher.sample](tests/Fixtures/samples/cypher.sample) | 87.8% | 885 | 100.0% | 100.0% | ✅ Identical | @@ -68,22 +68,22 @@ Generated with PHP 8.4.27, PCRE2 10.42 and Oniguruma 6.9.9. | dax | [dax.sample](tests/Fixtures/samples/dax.sample) | 34.5% | 60 | 100.0% | 100.0% | ✅ Identical | | desktop | [desktop.sample](tests/Fixtures/samples/desktop.sample) | 41.2% | 84 | 57.1% | 100.0% | ✅ Identical | | diff | [diff.sample](tests/Fixtures/samples/diff.sample) | 31.2% | 35 | 100.0% | 100.0% | ✅ Identical | -| djot | [djot.sample](tests/Fixtures/samples/djot.sample) | 92.0% | 387 | 95.3% | 95.6% | [Line 20](tests/Fixtures/samples/djot.sample#L20) | +| djot | [djot.sample](tests/Fixtures/samples/djot.sample) | 92.0% | 387 | 99.7% | 100.0% | ✅ Identical | | docker | [docker.sample](tests/Fixtures/samples/docker.sample) | 55.6% | 36 | 100.0% | 100.0% | ✅ Identical | | dotenv | [dotenv.sample](tests/Fixtures/samples/dotenv.sample) | 77.8% | 30 | 100.0% | 100.0% | ✅ Identical | -| dream-maker | [dream-maker.sample](tests/Fixtures/samples/dream-maker.sample) | 55.1% | 703 | 95.4% | 99.7% | [Line 41](tests/Fixtures/samples/dream-maker.sample#L41) | +| dream-maker | [dream-maker.sample](tests/Fixtures/samples/dream-maker.sample) | 51.9% | 703 | 96.0% | 100.0% | ✅ Identical | | edge | [edge.sample](tests/Fixtures/samples/edge.sample) | 54.5% | 147 | 100.0% | 100.0% | ✅ Identical | -| elixir | [elixir.sample](tests/Fixtures/samples/elixir.sample) | 71.5% | 1516 | 99.9% | 100.0% | ✅ Identical | +| elixir | [elixir.sample](tests/Fixtures/samples/elixir.sample) | 71.5% | 1516 | 100.0% | 100.0% | ✅ Identical | | elm | [elm.sample](tests/Fixtures/samples/elm.sample) | 52.7% | 240 | 100.0% | 100.0% | ✅ Identical | | emacs-lisp | [emacs-lisp.sample](tests/Fixtures/samples/emacs-lisp.sample) | 45.0% | 1331 | 100.0% | 100.0% | ✅ Identical | -| erb | [erb.sample](tests/Fixtures/samples/erb.sample) | 83.3% | 832 | 98.4% | 99.9% | [Line 14](tests/Fixtures/samples/erb.sample#L14) | -| erlang | [erlang.sample](tests/Fixtures/samples/erlang.sample) | 59.6% | 1984 | 99.8% | 99.8% | [Line 57](tests/Fixtures/samples/erlang.sample#L57) | +| erb | [erb.sample](tests/Fixtures/samples/erb.sample) | 83.3% | 832 | 98.6% | 100.0% | ✅ Identical | +| erlang | [erlang.sample](tests/Fixtures/samples/erlang.sample) | 59.6% | 1984 | 100.0% | 100.0% | ✅ Identical | | fennel | [fennel.sample](tests/Fixtures/samples/fennel.sample) | 50.0% | 130 | 100.0% | 100.0% | ✅ Identical | | fish | [fish.sample](tests/Fixtures/samples/fish.sample) | 68.8% | 648 | 100.0% | 100.0% | ✅ Identical | | fluent | [fluent.sample](tests/Fixtures/samples/fluent.sample) | 56.5% | 86 | 100.0% | 100.0% | ✅ Identical | -| fortran-fixed-form | [fortran-fixed-form.sample](tests/Fixtures/samples/fortran-fixed-form.sample) | 71.4% | 208 | 96.2% | 97.6% | [Line 17](tests/Fixtures/samples/fortran-fixed-form.sample#L17) | -| fortran-free-form | [fortran-free-form.sample](tests/Fixtures/samples/fortran-free-form.sample) | 50.6% | 1637 | 89.8% | 89.8% | [Line 27](tests/Fixtures/samples/fortran-free-form.sample#L27) | -| fsharp | [fsharp.sample](tests/Fixtures/samples/fsharp.sample) | 44.7% | 1170 | 99.7% | 100.0% | ✅ Identical | +| fortran-fixed-form | [fortran-fixed-form.sample](tests/Fixtures/samples/fortran-fixed-form.sample) | 71.4% | 208 | 98.6% | 100.0% | ✅ Identical | +| fortran-free-form | [fortran-free-form.sample](tests/Fixtures/samples/fortran-free-form.sample) | 51.9% | 1637 | 100.0% | 100.0% | ✅ Identical | +| fsharp | [fsharp.sample](tests/Fixtures/samples/fsharp.sample) | 44.7% | 1170 | 100.0% | 100.0% | ✅ Identical | | gdresource | [gdresource.sample](tests/Fixtures/samples/gdresource.sample) | 56.1% | 612 | 100.0% | 100.0% | ✅ Identical | | gdscript | [gdscript.sample](tests/Fixtures/samples/gdscript.sample) | 49.5% | 318 | 99.1% | 100.0% | ✅ Identical | | gdshader | [gdshader.sample](tests/Fixtures/samples/gdshader.sample) | 79.5% | 747 | 100.0% | 100.0% | ✅ Identical | @@ -92,33 +92,33 @@ Generated with PHP 8.4.27, PCRE2 10.42 and Oniguruma 6.9.9. | git-commit | [git-commit.sample](tests/Fixtures/samples/git-commit.sample) | 90.9% | 87 | 100.0% | 100.0% | ✅ Identical | | git-rebase | [git-rebase.sample](tests/Fixtures/samples/git-rebase.sample) | 100.0% | 97 | 97.9% | 97.9% | [Line 6](tests/Fixtures/samples/git-rebase.sample#L6) | | gleam | [gleam.sample](tests/Fixtures/samples/gleam.sample) | 92.6% | 517 | 100.0% | 100.0% | ✅ Identical | -| glimmer-js | [glimmer-js.sample](tests/Fixtures/samples/glimmer-js.sample) | 78.8% | 941 | 99.9% | 99.9% | [Line 43](tests/Fixtures/samples/glimmer-js.sample#L43) | +| glimmer-js | [glimmer-js.sample](tests/Fixtures/samples/glimmer-js.sample) | 78.8% | 941 | 100.0% | 100.0% | ✅ Identical | | glimmer-ts | [glimmer-ts.sample](tests/Fixtures/samples/glimmer-ts.sample) | 74.6% | 1004 | 100.0% | 100.0% | ✅ Identical | -| glsl | [glsl.sample](tests/Fixtures/samples/glsl.sample) | 85.7% | 888 | 95.2% | 100.0% | ✅ Identical | +| glsl | [glsl.sample](tests/Fixtures/samples/glsl.sample) | 85.7% | 888 | 100.0% | 100.0% | ✅ Identical | | gnuplot | [gnuplot.sample](tests/Fixtures/samples/gnuplot.sample) | 83.8% | 787 | 99.6% | 100.0% | ✅ Identical | -| go | [go.sample](tests/Fixtures/samples/go.sample) | 91.1% | 5245 | 96.9% | 100.0% | ✅ Identical | -| graphql | [graphql.sample](tests/Fixtures/samples/graphql.sample) | 73.0% | 856 | 51.4% | 51.8% | [Line 26](tests/Fixtures/samples/graphql.sample#L26) | -| groovy | [groovy.sample](tests/Fixtures/samples/groovy.sample) | 83.2% | 1180 | 22.8% | 22.8% | [Line 12](tests/Fixtures/samples/groovy.sample#L12) | -| hack | [hack.sample](tests/Fixtures/samples/hack.sample) | 49.7% | 1813 | 94.9% | 95.3% | [Line 107](tests/Fixtures/samples/hack.sample#L107) | -| haml | [haml.sample](tests/Fixtures/samples/haml.sample) | 59.0% | 667 | 97.2% | 99.0% | [Line 10](tests/Fixtures/samples/haml.sample#L10) | -| handlebars | [handlebars.sample](tests/Fixtures/samples/handlebars.sample) | 68.3% | 704 | 99.7% | 99.7% | [Line 13](tests/Fixtures/samples/handlebars.sample#L13) | -| haskell | [haskell.sample](tests/Fixtures/samples/haskell.sample) | 53.1% | 1167 | 50.8% | 99.1% | [Line 40](tests/Fixtures/samples/haskell.sample#L40) | +| go | [go.sample](tests/Fixtures/samples/go.sample) | 91.1% | 5245 | 97.5% | 100.0% | ✅ Identical | +| graphql | [graphql.sample](tests/Fixtures/samples/graphql.sample) | 89.9% | 856 | 100.0% | 100.0% | ✅ Identical | +| groovy | [groovy.sample](tests/Fixtures/samples/groovy.sample) | 85.9% | 1180 | 99.9% | 100.0% | ✅ Identical | +| hack | [hack.sample](tests/Fixtures/samples/hack.sample) | 54.0% | 1813 | 99.7% | 100.0% | ✅ Identical | +| haml | [haml.sample](tests/Fixtures/samples/haml.sample) | 56.6% | 667 | 98.2% | 100.0% | ✅ Identical | +| handlebars | [handlebars.sample](tests/Fixtures/samples/handlebars.sample) | 68.3% | 704 | 100.0% | 100.0% | ✅ Identical | +| haskell | [haskell.sample](tests/Fixtures/samples/haskell.sample) | 63.5% | 1167 | 92.9% | 100.0% | ✅ Identical | | haxe | [haxe.sample](tests/Fixtures/samples/haxe.sample) | 80.6% | 1613 | 100.0% | 100.0% | ✅ Identical | | hcl | [hcl.sample](tests/Fixtures/samples/hcl.sample) | 86.2% | 791 | 99.6% | 100.0% | ✅ Identical | | hjson | [hjson.sample](tests/Fixtures/samples/hjson.sample) | 45.9% | 346 | 5.8% | 100.0% | ✅ Identical | | hlsl | [hlsl.sample](tests/Fixtures/samples/hlsl.sample) | 96.2% | 572 | 100.0% | 100.0% | ✅ Identical | -| html | [html.sample](tests/Fixtures/samples/html.sample) | 98.8% | 1263 | 93.7% | 93.7% | [Line 82](tests/Fixtures/samples/html.sample#L82) | -| html-derivative | [html-derivative.sample](tests/Fixtures/samples/html-derivative.sample) | 100.0% | 843 | 99.9% | 99.9% | [Line 9](tests/Fixtures/samples/html-derivative.sample#L9) | +| html | [html.sample](tests/Fixtures/samples/html.sample) | 75.8% | 1263 | 100.0% | 100.0% | ✅ Identical | +| html-derivative | [html-derivative.sample](tests/Fixtures/samples/html-derivative.sample) | 100.0% | 843 | 100.0% | 100.0% | ✅ Identical | | http | [http.sample](tests/Fixtures/samples/http.sample) | 91.7% | 375 | 100.0% | 100.0% | ✅ Identical | -| hurl | [hurl.sample](tests/Fixtures/samples/hurl.sample) | 92.9% | 450 | 98.4% | 98.4% | [Line 9](tests/Fixtures/samples/hurl.sample#L9) | +| hurl | [hurl.sample](tests/Fixtures/samples/hurl.sample) | 85.7% | 450 | 100.0% | 100.0% | ✅ Identical | | hxml | [hxml.sample](tests/Fixtures/samples/hxml.sample) | 66.7% | 33 | 100.0% | 100.0% | ✅ Identical | | hy | [hy.sample](tests/Fixtures/samples/hy.sample) | 41.7% | 185 | 9.7% | 100.0% | ✅ Identical | -| imba | [imba.sample](tests/Fixtures/samples/imba.sample) | 45.4% | 1489 | 99.1% | 99.5% | [Line 9](tests/Fixtures/samples/imba.sample#L9) | +| imba | [imba.sample](tests/Fixtures/samples/imba.sample) | 45.4% | 1489 | 100.0% | 100.0% | ✅ Identical | | ini | [ini.sample](tests/Fixtures/samples/ini.sample) | 53.3% | 35 | 100.0% | 100.0% | ✅ Identical | | java | [java.sample](tests/Fixtures/samples/java.sample) | 92.5% | 2485 | 100.0% | 100.0% | ✅ Identical | | javascript | [javascript.sample](tests/Fixtures/samples/javascript.sample) | 93.6% | 6287 | 99.9% | 100.0% | ✅ Identical | | jinja | [jinja.sample](tests/Fixtures/samples/jinja.sample) | 91.9% | 723 | 100.0% | 100.0% | ✅ Identical | -| jison | [jison.sample](tests/Fixtures/samples/jison.sample) | 33.7% | 243 | 70.4% | 70.4% | [Line 4](tests/Fixtures/samples/jison.sample#L4) | +| jison | [jison.sample](tests/Fixtures/samples/jison.sample) | 23.2% | 243 | 100.0% | 100.0% | ✅ Identical | | json | [json.sample](tests/Fixtures/samples/json.sample) | 100.0% | 304 | 100.0% | 100.0% | ✅ Identical | | json5 | [json5.sample](tests/Fixtures/samples/json5.sample) | 46.4% | 229 | 100.0% | 100.0% | ✅ Identical | | jsonc | [jsonc.sample](tests/Fixtures/samples/jsonc.sample) | 73.9% | 145 | 100.0% | 100.0% | ✅ Identical | @@ -126,14 +126,14 @@ Generated with PHP 8.4.27, PCRE2 10.42 and Oniguruma 6.9.9. | jsonnet | [jsonnet.sample](tests/Fixtures/samples/jsonnet.sample) | 40.5% | 135 | 100.0% | 100.0% | ✅ Identical | | jssm | [jssm.sample](tests/Fixtures/samples/jssm.sample) | 30.0% | 97 | 100.0% | 100.0% | ✅ Identical | | jsx | [jsx.sample](tests/Fixtures/samples/jsx.sample) | 93.4% | 6610 | 99.9% | 100.0% | ✅ Identical | -| julia | [julia.sample](tests/Fixtures/samples/julia.sample) | 76.9% | 1033 | 99.3% | 100.0% | ✅ Identical | +| julia | [julia.sample](tests/Fixtures/samples/julia.sample) | 76.9% | 1033 | 99.7% | 100.0% | ✅ Identical | | kdl | [kdl.sample](tests/Fixtures/samples/kdl.sample) | 82.9% | 241 | 100.0% | 100.0% | ✅ Identical | | kotlin | [kotlin.sample](tests/Fixtures/samples/kotlin.sample) | 95.4% | 904 | 63.1% | 100.0% | ✅ Identical | | kusto | [kusto.sample](tests/Fixtures/samples/kusto.sample) | 95.0% | 551 | 99.5% | 100.0% | ✅ Identical | -| latex | [latex.sample](tests/Fixtures/samples/latex.sample) | 25.2% | 1151 | 53.3% | 53.6% | [Line 64](tests/Fixtures/samples/latex.sample#L64) | -| lean | [lean.sample](tests/Fixtures/samples/lean.sample) | 41.5% | 311 | 93.9% | 93.9% | [Line 5](tests/Fixtures/samples/lean.sample#L5) | +| latex | [latex.sample](tests/Fixtures/samples/latex.sample) | 25.6% | 1151 | 99.7% | 100.0% | ✅ Identical | +| lean | [lean.sample](tests/Fixtures/samples/lean.sample) | 36.6% | 311 | 100.0% | 100.0% | ✅ Identical | | less | [less.sample](tests/Fixtures/samples/less.sample) | 68.5% | 2260 | 100.0% | 100.0% | ✅ Identical | -| liquid | [liquid.sample](tests/Fixtures/samples/liquid.sample) | 67.6% | 812 | 99.1% | 100.0% | ✅ Identical | +| liquid | [liquid.sample](tests/Fixtures/samples/liquid.sample) | 67.6% | 812 | 99.5% | 100.0% | ✅ Identical | | llvm | [llvm.sample](tests/Fixtures/samples/llvm.sample) | 34.6% | 203 | 100.0% | 100.0% | ✅ Identical | | log | [log.sample](tests/Fixtures/samples/log.sample) | 80.6% | 299 | 96.3% | 100.0% | ✅ Identical | | logo | [logo.sample](tests/Fixtures/samples/logo.sample) | 100.0% | 57 | 100.0% | 100.0% | ✅ Identical | @@ -141,64 +141,64 @@ Generated with PHP 8.4.27, PCRE2 10.42 and Oniguruma 6.9.9. | luau | [luau.sample](tests/Fixtures/samples/luau.sample) | 88.6% | 760 | 100.0% | 100.0% | ✅ Identical | | make | [make.sample](tests/Fixtures/samples/make.sample) | 73.3% | 521 | 100.0% | 100.0% | ✅ Identical | | maml | [maml.sample](tests/Fixtures/samples/maml.sample) | 66.7% | 98 | 100.0% | 100.0% | ✅ Identical | -| markdown | [markdown.sample](tests/Fixtures/samples/markdown.sample) | 97.7% | 1606 | 88.6% | 91.9% | [Line 1](tests/Fixtures/samples/markdown.sample#L1) | -| marko | [marko.sample](tests/Fixtures/samples/marko.sample) | 45.6% | 941 | 80.4% | 80.4% | [Line 14](tests/Fixtures/samples/marko.sample#L14) | +| markdown | [markdown.sample](tests/Fixtures/samples/markdown.sample) | 92.3% | 1606 | 95.7% | 98.9% | [Line 182](tests/Fixtures/samples/markdown.sample#L182) | +| marko | [marko.sample](tests/Fixtures/samples/marko.sample) | 47.3% | 941 | 100.0% | 100.0% | ✅ Identical | | matlab | [matlab.sample](tests/Fixtures/samples/matlab.sample) | 59.1% | 435 | 99.8% | 100.0% | ✅ Identical | -| mdc | [mdc.sample](tests/Fixtures/samples/mdc.sample) | 41.0% | 89 | 67.4% | 79.8% | [Line 1](tests/Fixtures/samples/mdc.sample#L1) | -| mdx | [mdx.sample](tests/Fixtures/samples/mdx.sample) | 19.1% | 665 | 87.8% | 94.0% | [Line 26](tests/Fixtures/samples/mdx.sample#L26) | +| mdc | [mdc.sample](tests/Fixtures/samples/mdc.sample) | 35.9% | 89 | 87.6% | 100.0% | ✅ Identical | +| mdx | [mdx.sample](tests/Fixtures/samples/mdx.sample) | 18.9% | 665 | 91.1% | 100.0% | ✅ Identical | | mermaid | [mermaid.sample](tests/Fixtures/samples/mermaid.sample) | 76.6% | 1026 | 100.0% | 100.0% | ✅ Identical | | mipsasm | [mipsasm.sample](tests/Fixtures/samples/mipsasm.sample) | 55.6% | 79 | 100.0% | 100.0% | ✅ Identical | | mojo | [mojo.sample](tests/Fixtures/samples/mojo.sample) | 46.9% | 1779 | 100.0% | 100.0% | ✅ Identical | | move | [move.sample](tests/Fixtures/samples/move.sample) | 81.6% | 914 | 100.0% | 100.0% | ✅ Identical | | narrat | [narrat.sample](tests/Fixtures/samples/narrat.sample) | 65.7% | 307 | 100.0% | 100.0% | ✅ Identical | | neon | [neon.sample](tests/Fixtures/samples/neon.sample) | 90.6% | 384 | 100.0% | 100.0% | ✅ Identical | -| nextflow | [nextflow.sample](tests/Fixtures/samples/nextflow.sample) | 46.3% | 182 | 92.9% | 92.9% | [Line 74](tests/Fixtures/samples/nextflow.sample#L74) | -| nginx | [nginx.sample](tests/Fixtures/samples/nginx.sample) | 54.6% | 766 | 99.7% | 100.0% | ✅ Identical | +| nextflow | [nextflow.sample](tests/Fixtures/samples/nextflow.sample) | 39.0% | 182 | 100.0% | 100.0% | ✅ Identical | +| nginx | [nginx.sample](tests/Fixtures/samples/nginx.sample) | 54.6% | 766 | 100.0% | 100.0% | ✅ Identical | | nim | [nim.sample](tests/Fixtures/samples/nim.sample) | 42.1% | 1154 | 100.0% | 100.0% | ✅ Identical | | nix | [nix.sample](tests/Fixtures/samples/nix.sample) | 45.3% | 213 | 100.0% | 100.0% | ✅ Identical | | nushell | [nushell.sample](tests/Fixtures/samples/nushell.sample) | 39.8% | 566 | 100.0% | 100.0% | ✅ Identical | -| objective-c | [objective-c.sample](tests/Fixtures/samples/objective-c.sample) | 41.8% | 1400 | 26.1% | 27.5% | [Line 1](tests/Fixtures/samples/objective-c.sample#L1) | -| objective-cpp | [objective-cpp.sample](tests/Fixtures/samples/objective-cpp.sample) | 40.8% | 1643 | 19.5% | 20.5% | [Line 3](tests/Fixtures/samples/objective-cpp.sample#L3) | -| ocaml | [ocaml.sample](tests/Fixtures/samples/ocaml.sample) | 55.1% | 1370 | 99.0% | 99.0% | [Line 58](tests/Fixtures/samples/ocaml.sample#L58) | +| objective-c | [objective-c.sample](tests/Fixtures/samples/objective-c.sample) | 34.4% | 1400 | 98.6% | 100.0% | ✅ Identical | +| objective-cpp | [objective-cpp.sample](tests/Fixtures/samples/objective-cpp.sample) | 23.6% | 1643 | 99.0% | 100.0% | ✅ Identical | +| ocaml | [ocaml.sample](tests/Fixtures/samples/ocaml.sample) | 58.3% | 1370 | 100.0% | 100.0% | ✅ Identical | | pascal | [pascal.sample](tests/Fixtures/samples/pascal.sample) | 32.0% | 316 | 100.0% | 100.0% | ✅ Identical | -| perl | [perl.sample](tests/Fixtures/samples/perl.sample) | 40.6% | 1330 | 97.0% | 98.5% | [Line 75](tests/Fixtures/samples/perl.sample#L75) | +| perl | [perl.sample](tests/Fixtures/samples/perl.sample) | 43.5% | 1330 | 98.5% | 100.0% | ✅ Identical | | php | [php.sample](tests/Fixtures/samples/php.sample) | 96.8% | 4772 | 99.6% | 100.0% | ✅ Identical | | pkl | [pkl.sample](tests/Fixtures/samples/pkl.sample) | 60.3% | 936 | 100.0% | 100.0% | ✅ Identical | | plsql | [plsql.sample](tests/Fixtures/samples/plsql.sample) | 86.7% | 695 | 100.0% | 100.0% | ✅ Identical | | polar | [polar.sample](tests/Fixtures/samples/polar.sample) | 61.2% | 709 | 97.2% | 100.0% | ✅ Identical | | postcss | [postcss.sample](tests/Fixtures/samples/postcss.sample) | 84.9% | 610 | 100.0% | 100.0% | ✅ Identical | | powerquery | [powerquery.sample](tests/Fixtures/samples/powerquery.sample) | 46.9% | 162 | 100.0% | 100.0% | ✅ Identical | -| powershell | [powershell.sample](tests/Fixtures/samples/powershell.sample) | 69.8% | 1128 | 98.8% | 100.0% | ✅ Identical | +| powershell | [powershell.sample](tests/Fixtures/samples/powershell.sample) | 69.8% | 1128 | 100.0% | 100.0% | ✅ Identical | | prisma | [prisma.sample](tests/Fixtures/samples/prisma.sample) | 79.4% | 165 | 100.0% | 100.0% | ✅ Identical | | prolog | [prolog.sample](tests/Fixtures/samples/prolog.sample) | 69.0% | 810 | 95.4% | 100.0% | ✅ Identical | | proto | [proto.sample](tests/Fixtures/samples/proto.sample) | 63.4% | 175 | 100.0% | 100.0% | ✅ Identical | -| pug | [pug.sample](tests/Fixtures/samples/pug.sample) | 65.4% | 551 | 96.2% | 97.1% | [Line 10](tests/Fixtures/samples/pug.sample#L10) | +| pug | [pug.sample](tests/Fixtures/samples/pug.sample) | 65.4% | 551 | 99.6% | 100.0% | ✅ Identical | | puppet | [puppet.sample](tests/Fixtures/samples/puppet.sample) | 67.1% | 810 | 99.9% | 100.0% | ✅ Identical | -| purescript | [purescript.sample](tests/Fixtures/samples/purescript.sample) | 38.3% | 572 | 98.1% | 99.5% | [Line 19](tests/Fixtures/samples/purescript.sample#L19) | +| purescript | [purescript.sample](tests/Fixtures/samples/purescript.sample) | 38.3% | 572 | 98.1% | 100.0% | ✅ Identical | | python | [python.sample](tests/Fixtures/samples/python.sample) | 92.0% | 3054 | 100.0% | 100.0% | ✅ Identical | | qml | [qml.sample](tests/Fixtures/samples/qml.sample) | 42.3% | 113 | 100.0% | 100.0% | ✅ Identical | | qmldir | [qmldir.sample](tests/Fixtures/samples/qmldir.sample) | 100.0% | 22 | 100.0% | 100.0% | ✅ Identical | | qss | [qss.sample](tests/Fixtures/samples/qss.sample) | 54.3% | 155 | 100.0% | 100.0% | ✅ Identical | | r | [r.sample](tests/Fixtures/samples/r.sample) | 83.2% | 1128 | 100.0% | 100.0% | ✅ Identical | -| racket | [racket.sample](tests/Fixtures/samples/racket.sample) | 43.9% | 1027 | 84.6% | 85.2% | [Line 3](tests/Fixtures/samples/racket.sample#L3) | +| racket | [racket.sample](tests/Fixtures/samples/racket.sample) | 43.9% | 1027 | 85.2% | 85.2% | [Line 3](tests/Fixtures/samples/racket.sample#L3) | | raku | [raku.sample](tests/Fixtures/samples/raku.sample) | 55.6% | 668 | 100.0% | 100.0% | ✅ Identical | -| razor | [razor.sample](tests/Fixtures/samples/razor.sample) | 79.0% | 1014 | 84.2% | 90.8% | [Line 30](tests/Fixtures/samples/razor.sample#L30) | +| razor | [razor.sample](tests/Fixtures/samples/razor.sample) | 79.0% | 1014 | 94.0% | 100.0% | ✅ Identical | | reg | [reg.sample](tests/Fixtures/samples/reg.sample) | 44.4% | 61 | 86.9% | 100.0% | ✅ Identical | | regexp | [regexp.sample](tests/Fixtures/samples/regexp.sample) | 88.1% | 335 | 100.0% | 100.0% | ✅ Identical | | rel | [rel.sample](tests/Fixtures/samples/rel.sample) | 40.0% | 241 | 100.0% | 100.0% | ✅ Identical | | riscv | [riscv.sample](tests/Fixtures/samples/riscv.sample) | 34.0% | 109 | 100.0% | 100.0% | ✅ Identical | -| rosmsg | [rosmsg.sample](tests/Fixtures/samples/rosmsg.sample) | 97.9% | 240 | 100.0% | 100.0% | ✅ Identical | -| rst | [rst.sample](tests/Fixtures/samples/rst.sample) | 64.6% | 271 | 91.1% | 91.1% | [Line 11](tests/Fixtures/samples/rst.sample#L11) | -| ruby | [ruby.sample](tests/Fixtures/samples/ruby.sample) | 93.9% | 2661 | 94.1% | 96.7% | [Line 7](tests/Fixtures/samples/ruby.sample#L7) | +| rosmsg | [rosmsg.sample](tests/Fixtures/samples/rosmsg.sample) | 98.0% | 240 | 100.0% | 100.0% | ✅ Identical | +| rst | [rst.sample](tests/Fixtures/samples/rst.sample) | 64.6% | 271 | 100.0% | 100.0% | ✅ Identical | +| ruby | [ruby.sample](tests/Fixtures/samples/ruby.sample) | 95.2% | 2661 | 97.4% | 100.0% | ✅ Identical | | rust | [rust.sample](tests/Fixtures/samples/rust.sample) | 92.6% | 1300 | 100.0% | 100.0% | ✅ Identical | | sas | [sas.sample](tests/Fixtures/samples/sas.sample) | 97.1% | 490 | 99.4% | 100.0% | ✅ Identical | | sass | [sass.sample](tests/Fixtures/samples/sass.sample) | 85.9% | 492 | 100.0% | 100.0% | ✅ Identical | -| scala | [scala.sample](tests/Fixtures/samples/scala.sample) | 92.3% | 2003 | 99.7% | 99.7% | [Line 198](tests/Fixtures/samples/scala.sample#L198) | +| scala | [scala.sample](tests/Fixtures/samples/scala.sample) | 93.5% | 2003 | 100.0% | 100.0% | ✅ Identical | | scheme | [scheme.sample](tests/Fixtures/samples/scheme.sample) | 36.8% | 117 | 100.0% | 100.0% | ✅ Identical | -| scss | [scss.sample](tests/Fixtures/samples/scss.sample) | 91.1% | 1551 | 98.5% | 98.5% | [Line 12](tests/Fixtures/samples/scss.sample#L12) | +| scss | [scss.sample](tests/Fixtures/samples/scss.sample) | 89.9% | 1551 | 100.0% | 100.0% | ✅ Identical | | sdbl | [sdbl.sample](tests/Fixtures/samples/sdbl.sample) | 30.4% | 60 | 100.0% | 100.0% | ✅ Identical | | shaderlab | [shaderlab.sample](tests/Fixtures/samples/shaderlab.sample) | 30.8% | 134 | 100.0% | 100.0% | ✅ Identical | -| shellscript | [shellscript.sample](tests/Fixtures/samples/shellscript.sample) | 87.2% | 1513 | 94.2% | 94.9% | [Line 45](tests/Fixtures/samples/shellscript.sample#L45) | +| shellscript | [shellscript.sample](tests/Fixtures/samples/shellscript.sample) | 88.2% | 1513 | 99.7% | 100.0% | ✅ Identical | | shellsession | [shellsession.sample](tests/Fixtures/samples/shellsession.sample) | 100.0% | 24 | 87.5% | 87.5% | [Line 1](tests/Fixtures/samples/shellsession.sample#L1) | | smalltalk | [smalltalk.sample](tests/Fixtures/samples/smalltalk.sample) | 60.8% | 79 | 100.0% | 100.0% | ✅ Identical | | solidity | [solidity.sample](tests/Fixtures/samples/solidity.sample) | 86.4% | 1155 | 100.0% | 100.0% | ✅ Identical | @@ -207,24 +207,24 @@ Generated with PHP 8.4.27, PCRE2 10.42 and Oniguruma 6.9.9. | splunk | [splunk.sample](tests/Fixtures/samples/splunk.sample) | 52.4% | 147 | 100.0% | 100.0% | ✅ Identical | | sql | [sql.sample](tests/Fixtures/samples/sql.sample) | 90.4% | 1035 | 87.7% | 100.0% | ✅ Identical | | ssh-config | [ssh-config.sample](tests/Fixtures/samples/ssh-config.sample) | 64.3% | 131 | 100.0% | 100.0% | ✅ Identical | -| stata | [stata.sample](tests/Fixtures/samples/stata.sample) | 56.7% | 1162 | 99.8% | 99.8% | [Line 45](tests/Fixtures/samples/stata.sample#L45) | -| stylus | [stylus.sample](tests/Fixtures/samples/stylus.sample) | 79.2% | 713 | 98.9% | 98.9% | [Line 90](tests/Fixtures/samples/stylus.sample#L90) | -| svelte | [svelte.sample](tests/Fixtures/samples/svelte.sample) | 52.2% | 1434 | 51.4% | 60.0% | [Line 20](tests/Fixtures/samples/svelte.sample#L20) | -| swift | [swift.sample](tests/Fixtures/samples/swift.sample) | 90.5% | 4002 | 60.9% | 99.5% | [Line 61](tests/Fixtures/samples/swift.sample#L61) | +| stata | [stata.sample](tests/Fixtures/samples/stata.sample) | 56.7% | 1162 | 99.9% | 99.9% | [Line 57](tests/Fixtures/samples/stata.sample#L57) | +| stylus | [stylus.sample](tests/Fixtures/samples/stylus.sample) | 80.0% | 713 | 99.6% | 100.0% | ✅ Identical | +| svelte | [svelte.sample](tests/Fixtures/samples/svelte.sample) | 51.6% | 1434 | 91.4% | 100.0% | ✅ Identical | +| swift | [swift.sample](tests/Fixtures/samples/swift.sample) | 90.3% | 4002 | 58.0% | 99.9% | [Line 419](tests/Fixtures/samples/swift.sample#L419) | | system-verilog | [system-verilog.sample](tests/Fixtures/samples/system-verilog.sample) | 72.3% | 1392 | 75.5% | 100.0% | ✅ Identical | | systemd | [systemd.sample](tests/Fixtures/samples/systemd.sample) | 32.5% | 30 | 100.0% | 100.0% | ✅ Identical | | talonscript | [talonscript.sample](tests/Fixtures/samples/talonscript.sample) | 31.4% | 502 | 100.0% | 100.0% | ✅ Identical | | tasl | [tasl.sample](tests/Fixtures/samples/tasl.sample) | 70.0% | 97 | 100.0% | 100.0% | ✅ Identical | -| tcl | [tcl.sample](tests/Fixtures/samples/tcl.sample) | 81.8% | 702 | 72.4% | 72.4% | [Line 76](tests/Fixtures/samples/tcl.sample#L76) | -| templ | [templ.sample](tests/Fixtures/samples/templ.sample) | 46.0% | 778 | 56.4% | 100.0% | ✅ Identical | +| tcl | [tcl.sample](tests/Fixtures/samples/tcl.sample) | 83.8% | 702 | 100.0% | 100.0% | ✅ Identical | +| templ | [templ.sample](tests/Fixtures/samples/templ.sample) | 46.0% | 778 | 56.8% | 100.0% | ✅ Identical | | terraform | [terraform.sample](tests/Fixtures/samples/terraform.sample) | 87.8% | 1041 | 100.0% | 100.0% | ✅ Identical | -| tex | [tex.sample](tests/Fixtures/samples/tex.sample) | 40.5% | 144 | 93.8% | 93.8% | [Line 24](tests/Fixtures/samples/tex.sample#L24) | +| tex | [tex.sample](tests/Fixtures/samples/tex.sample) | 40.5% | 144 | 100.0% | 100.0% | ✅ Identical | | toml | [toml.sample](tests/Fixtures/samples/toml.sample) | 40.7% | 133 | 100.0% | 100.0% | ✅ Identical | | ts-tags | [ts-tags.sample](tests/Fixtures/samples/ts-tags.sample) | 100.0% | 142 | 100.0% | 100.0% | ✅ Identical | | tsv | [tsv.sample](tests/Fixtures/samples/tsv.sample) | 100.0% | 25 | 100.0% | 100.0% | ✅ Identical | -| tsx | [tsx.sample](tests/Fixtures/samples/tsx.sample) | 93.1% | 5446 | 99.7% | 100.0% | ✅ Identical | +| tsx | [tsx.sample](tests/Fixtures/samples/tsx.sample) | 93.1% | 5446 | 99.8% | 100.0% | ✅ Identical | | turtle | [turtle.sample](tests/Fixtures/samples/turtle.sample) | 38.1% | 111 | 100.0% | 100.0% | ✅ Identical | -| twig | [twig.sample](tests/Fixtures/samples/twig.sample) | 71.8% | 1380 | 99.7% | 99.9% | [Line 40](tests/Fixtures/samples/twig.sample#L40) | +| twig | [twig.sample](tests/Fixtures/samples/twig.sample) | 71.8% | 1380 | 100.0% | 100.0% | ✅ Identical | | txt | [txt.sample](tests/Fixtures/samples/txt.sample) | 100.0% | 26 | 100.0% | 100.0% | ✅ Identical | | typescript | [typescript.sample](tests/Fixtures/samples/typescript.sample) | 93.8% | 5429 | 99.9% | 100.0% | ✅ Identical | | typespec | [typespec.sample](tests/Fixtures/samples/typespec.sample) | 32.0% | 212 | 100.0% | 100.0% | ✅ Identical | @@ -235,16 +235,16 @@ Generated with PHP 8.4.27, PCRE2 10.42 and Oniguruma 6.9.9. | verilog | [verilog.sample](tests/Fixtures/samples/verilog.sample) | 34.3% | 96 | 100.0% | 100.0% | ✅ Identical | | vhdl | [vhdl.sample](tests/Fixtures/samples/vhdl.sample) | 81.1% | 1465 | 99.7% | 100.0% | ✅ Identical | | viml | [viml.sample](tests/Fixtures/samples/viml.sample) | 81.3% | 639 | 99.1% | 100.0% | ✅ Identical | -| vue | [vue.sample](tests/Fixtures/samples/vue.sample) | 40.4% | 1443 | 98.5% | 98.7% | [Line 29](tests/Fixtures/samples/vue.sample#L29) | -| vue-html | [vue-html.sample](tests/Fixtures/samples/vue-html.sample) | 47.2% | 1038 | 91.3% | 91.3% | [Line 35](tests/Fixtures/samples/vue-html.sample#L35) | -| vue-vine | [vue-vine.sample](tests/Fixtures/samples/vue-vine.sample) | 44.6% | 2438 | 99.3% | 99.7% | [Line 199](tests/Fixtures/samples/vue-vine.sample#L199) | +| vue | [vue.sample](tests/Fixtures/samples/vue.sample) | 40.4% | 1443 | 100.0% | 100.0% | ✅ Identical | +| vue-html | [vue-html.sample](tests/Fixtures/samples/vue-html.sample) | 54.7% | 1038 | 100.0% | 100.0% | ✅ Identical | +| vue-vine | [vue-vine.sample](tests/Fixtures/samples/vue-vine.sample) | 44.6% | 2438 | 100.0% | 100.0% | ✅ Identical | | vyper | [vyper.sample](tests/Fixtures/samples/vyper.sample) | 22.3% | 1245 | 100.0% | 100.0% | ✅ Identical | | wasm | [wasm.sample](tests/Fixtures/samples/wasm.sample) | 59.5% | 1603 | 100.0% | 100.0% | ✅ Identical | | wgsl | [wgsl.sample](tests/Fixtures/samples/wgsl.sample) | 46.7% | 121 | 100.0% | 100.0% | ✅ Identical | -| wikitext | [wikitext.sample](tests/Fixtures/samples/wikitext.sample) | 100.0% | 361 | 1.1% | 1.1% | [Line 1](tests/Fixtures/samples/wikitext.sample#L1) | +| wikitext | [wikitext.sample](tests/Fixtures/samples/wikitext.sample) | 4.4% | 361 | 100.0% | 100.0% | ✅ Identical | | wit | [wit.sample](tests/Fixtures/samples/wit.sample) | 52.6% | 273 | 98.5% | 100.0% | ✅ Identical | | wolfram | [wolfram.sample](tests/Fixtures/samples/wolfram.sample) | 29.5% | 2725 | 100.0% | 100.0% | ✅ Identical | -| xml | [xml.sample](tests/Fixtures/samples/xml.sample) | 31.2% | 782 | 100.0% | 100.0% | ✅ Identical | +| xml | [xml.sample](tests/Fixtures/samples/xml.sample) | 29.4% | 782 | 100.0% | 100.0% | ✅ Identical | | xsl | [xsl.sample](tests/Fixtures/samples/xsl.sample) | 71.4% | 374 | 100.0% | 100.0% | ✅ Identical | | yaml | [yaml.sample](tests/Fixtures/samples/yaml.sample) | 96.8% | 438 | 100.0% | 100.0% | ✅ Identical | | zenscript | [zenscript.sample](tests/Fixtures/samples/zenscript.sample) | 45.8% | 230 | 100.0% | 100.0% | ✅ Identical | diff --git a/src/Grammar/BeginEndPattern.php b/src/Grammar/BeginEndPattern.php index 52f4167c..cffd1425 100644 --- a/src/Grammar/BeginEndPattern.php +++ b/src/Grammar/BeginEndPattern.php @@ -10,6 +10,11 @@ class BeginEndPattern implements HasContentNameInterface, PatternInterface { + /** + * Whether every nested pattern includes a rule or grammar that doesn't exist. + */ + private ?bool $missing = null; + public function __construct( public int $id, public Regex $begin, @@ -21,6 +26,7 @@ public function __construct( public array $captures = [], public array $patterns = [], public bool $injection = false, + public bool $applyEndPatternLast = false, ) {} public function getScopeName(array $captures): ?string @@ -53,6 +59,11 @@ public function getContentName(array $captures): ?string */ public function compile(ParsedGrammar $grammar, GrammarRepositoryInterface $grammars, bool $allowA, bool $allowG): array { + // Like vscode-textmate, this is decided once, the first time the rule is compiled. + if ($this->missing ??= IncludePattern::allMissing($this->patterns, $grammar, $grammars)) { + return []; + } + return [ [$this, $this->begin->get($allowA, $allowG)], ]; @@ -73,6 +84,7 @@ public function createEndPattern(MatchedPattern $matched): EndPattern captures: $this->captures, patterns: $this->patterns, injection: $this->injection, + applyEndPatternLast: $this->applyEndPatternLast, ); } diff --git a/src/Grammar/BeginWhilePattern.php b/src/Grammar/BeginWhilePattern.php index b59ea177..70dcc560 100644 --- a/src/Grammar/BeginWhilePattern.php +++ b/src/Grammar/BeginWhilePattern.php @@ -10,6 +10,11 @@ class BeginWhilePattern implements HasContentNameInterface, PatternInterface { + /** + * Whether every nested pattern includes a rule or grammar that doesn't exist. + */ + private ?bool $missing = null; + public function __construct( public int $id, public Regex $begin, @@ -34,7 +39,7 @@ public function getScopeName(array $captures): ?string public function captures(): array { - return count(array_filter($this->beginCaptures)) > 0 ? array_filter($this->beginCaptures) : $this->captures; + return count(array_filter($this->beginCaptures)) > 0 ? $this->beginCaptures : $this->captures; } public function getContentName(array $captures): ?string @@ -53,6 +58,11 @@ public function getContentName(array $captures): ?string */ public function compile(ParsedGrammar $grammar, GrammarRepositoryInterface $grammars, bool $allowA, bool $allowG): array { + // Like vscode-textmate, this is decided once, the first time the rule is compiled. + if ($this->missing ??= IncludePattern::allMissing($this->patterns, $grammar, $grammars)) { + return []; + } + return [ [$this, $this->begin->get($allowA, $allowG)], ]; diff --git a/src/Grammar/EndPattern.php b/src/Grammar/EndPattern.php index 55a55333..c975b0df 100644 --- a/src/Grammar/EndPattern.php +++ b/src/Grammar/EndPattern.php @@ -19,6 +19,7 @@ public function __construct( public array $captures = [], public array $patterns = [], public bool $injection = false, + public bool $applyEndPatternLast = false, ) {} public function getScopeName(array $captures): ?string @@ -42,15 +43,15 @@ public function captures(): array */ public function compile(ParsedGrammar $grammar, GrammarRepositoryInterface $grammars, bool $allowA, bool $allowG): array { - $compiled = [ - [$this, $this->end->get($allowA, $allowG, $this->begin->matches)], - ]; + $end = [$this, $this->end->get($allowA, $allowG, $this->begin->matches)]; + $compiled = []; foreach ($this->patterns as $pattern) { $compiled = array_merge($compiled, $pattern->compile($grammar, $grammars, $allowA, $allowG)); } - return $compiled; + // The end pattern wins a tie with the nested patterns, unless `applyEndPatternLast` is set. + return $this->applyEndPatternLast ? [...$compiled, $end] : [$end, ...$compiled]; } public function getId(): int diff --git a/src/Grammar/GrammarParser.php b/src/Grammar/GrammarParser.php index 55a2086a..55ad90b6 100644 --- a/src/Grammar/GrammarParser.php +++ b/src/Grammar/GrammarParser.php @@ -5,7 +5,6 @@ use Phiki\Contracts\InjectionSelectorParserInputInterface; use Phiki\Contracts\PatternInterface; use Phiki\Exceptions\MissingRequiredGrammarKeyException; -use Phiki\Exceptions\UnreachableException; use Phiki\Grammar\Injections\Composite; use Phiki\Grammar\Injections\Expression; use Phiki\Grammar\Injections\Filter; @@ -26,6 +25,21 @@ class GrammarParser protected int $id = 0; + /** + * Repository keys for the names that `#name` includes refer to in the rule being parsed, for names + * defined by the repository of an enclosing rule rather than the grammar's own repository. + * + * @var array + */ + protected array $references = []; + + /** + * Rules from the repositories of rules, keyed so they can't clash with the grammar's own repository. + * + * @var array + */ + protected array $nestedRepository = []; + public function parse(array $grammar): ParsedGrammar { if (! isset($grammar['scopeName'])) { @@ -33,6 +47,8 @@ public function parse(array $grammar): ParsedGrammar } $this->scopeName = $scopeName = $grammar['scopeName']; + $this->references = []; + $this->nestedRepository = []; $patterns = $this->patterns($grammar['patterns'] ?? []); $repository = []; @@ -51,11 +67,15 @@ public function parse(array $grammar): ParsedGrammar $name = $grammar['name'] ?? null; - return new ParsedGrammar($name, $scopeName, $patterns, $repository, $injections); + return new ParsedGrammar($name, $scopeName, $patterns, $repository + $this->nestedRepository, $injections); } protected function pattern(array $pattern): PatternInterface|false { + // vscode-textmate treats an empty name the same as no name. + $pattern = array_filter($pattern, fn ($value, $key) => ! in_array($key, ['name', 'contentName'], true) || ($value !== '' && $value !== null), ARRAY_FILTER_USE_BOTH); + + // The checks below follow how vscode-textmate decides what kind of rule a pattern is. if (isset($pattern['match']) && $pattern['match'] !== '') { return new MatchPattern( $this->id(), @@ -66,51 +86,75 @@ protected function pattern(array $pattern): PatternInterface|false ); } - if (isset($pattern['begin'], $pattern['end']) && $pattern['begin'] !== '' && $pattern['end'] !== '') { - return new BeginEndPattern( + // A rule without `begin` can have its own repository. `#name` includes inside the rule, including + // inside that repository, resolve to its rules before the enclosing ones. + if (! isset($pattern['begin']) && isset($pattern['repository']) && is_array($pattern['repository'])) { + $references = $this->references; + + foreach (array_keys($pattern['repository']) as $name) { + $this->references[$name] = $name."\0".$this->id(); + } + + try { + foreach ($pattern['repository'] as $name => $rule) { + if (is_array($rule) && ($parsed = $this->pattern($rule))) { + $this->nestedRepository[$this->references[$name]] = $parsed; + } + } + + unset($pattern['repository']); + + return $this->pattern($pattern); + } finally { + $this->references = $references; + } + } + + // An empty begin matches straight away, but mbregex can't search for an empty pattern. + if (($pattern['begin'] ?? null) === '') { + $pattern['begin'] = '(?:)'; + } + + if (isset($pattern['begin']) && ($pattern['while'] ?? '') !== '') { + return new BeginWhilePattern( $this->id(), new Regex($pattern['begin']), - new Regex($pattern['end']), + new Regex($pattern['while']), $pattern['name'] ?? null, $pattern['contentName'] ?? null, $this->captures($pattern['beginCaptures'] ?? []), - $this->captures($pattern['endCaptures'] ?? []), + $this->captures($pattern['whileCaptures'] ?? []), $this->captures($pattern['captures'] ?? []), $this->patterns($pattern['patterns'] ?? []), injection: $this->injection, ); } - if (isset($pattern['begin'], $pattern['while'])) { - return new BeginWhilePattern( + if (isset($pattern['begin'])) { + return new BeginEndPattern( $this->id(), new Regex($pattern['begin']), - new Regex($pattern['while']), + // A missing or empty end never matches, so the rule continues to the end of the code. + new Regex(($pattern['end'] ?? '') === '' ? '(?!)' : $pattern['end']), $pattern['name'] ?? null, $pattern['contentName'] ?? null, $this->captures($pattern['beginCaptures'] ?? []), - $this->captures($pattern['whileCaptures'] ?? []), + $this->captures($pattern['endCaptures'] ?? []), $this->captures($pattern['captures'] ?? []), $this->patterns($pattern['patterns'] ?? []), injection: $this->injection, + applyEndPatternLast: (bool) ($pattern['applyEndPatternLast'] ?? false), ); } - // This is more of a special case because it shouldn't ever happen, but we want - // to be graceful and treat a standalone begin as a match. - if (isset($pattern['begin']) && ! isset($pattern['end']) && ! isset($pattern['while'])) { - return new MatchPattern( - $this->id(), - new Regex($pattern['begin']), - $pattern['name'] ?? null, - $this->captures($pattern['beginCaptures'] ?? $pattern['captures'] ?? []), - injection: $this->injection, - ); + if (isset($pattern['patterns'])) { + return new CollectionPattern($this->id(), $this->patterns($pattern['patterns']), injection: $this->injection); } if (isset($pattern['include'])) { if (str_starts_with($pattern['include'], '#')) { - [$reference, $scopeName] = [substr($pattern['include'], 1), $this->scopeName]; + $reference = substr($pattern['include'], 1); + [$reference, $scopeName] = [$this->references[$reference] ?? $reference, $this->scopeName]; } elseif ($pattern['include'] === '$self') { [$reference, $scopeName] = ['$self', $this->scopeName]; } elseif ($pattern['include'] === '$base') { @@ -124,10 +168,6 @@ protected function pattern(array $pattern): PatternInterface|false return new IncludePattern($this->id(), $reference, $scopeName, injection: $this->injection); } - if (isset($pattern['patterns'])) { - return new CollectionPattern($this->id(), $this->patterns($pattern['patterns']), injection: $this->injection); - } - if (array_is_list($pattern)) { return new CollectionPattern($this->id(), $this->patterns($pattern), injection: $this->injection); } @@ -153,6 +193,10 @@ protected function captures(array $captures): array $result = []; foreach ($captures as $index => $capture) { + if ($capture === null) { + continue; + } + $result[$index] = $this->capture($capture, strval($index)); } @@ -171,36 +215,40 @@ protected function captures(array $captures): array protected function capture(array|string $capture, string $index): Capture { if (is_string($capture)) { - return new Capture($this->id(), $index, $capture, new CollectionPattern($this->id(), [], $this->injection)); + return new Capture($this->id(), $index, $capture === '' ? null : $capture, new CollectionPattern($this->id(), [], $this->injection)); } - return new Capture($this->id(), $index, $capture['name'] ?? null, new CollectionPattern($this->id(), $this->patterns($capture['patterns'] ?? []), $this->injection)); + return new Capture($this->id(), $index, ($capture['name'] ?? '') === '' ? null : $capture['name'], new CollectionPattern($this->id(), $this->patterns($capture['patterns'] ?? []), $this->injection)); } protected function injection(string $selector, array $injection): Injection { $input = new class($selector) implements InjectionSelectorParserInputInterface { - private string $selector; + /** + * @var list + */ + private array $tokens; private int $offset = 0; public function __construct(string $selector) { - // Remove whitespace from the selector so we don't need to skip it in the parser. - // Only exception is when the whitespace is between two letters, because it means - // it's part of a path / scope pattern. - $this->selector = preg_replace('/(?tokens = $matches[0]; } public function current(): ?string { - return $this->selector[$this->offset] ?? null; + return $this->tokens[$this->offset] ?? null; } public function peek(): ?string { - return $this->selector[$this->offset + 1] ?? null; + return $this->tokens[$this->offset + 1] ?? null; } public function next(): void @@ -231,119 +279,92 @@ protected function selector(InjectionSelectorParserInputInterface $input): Selec return new Selector($composites); } + /** + * Parse operands joined by `|`. Operands next to each other, or joined by `&` or `-`, bind more tightly + * than `|`, so `a | b - c` means `a | (b - c)`, as in vscode-textmate. + */ protected function composite(InjectionSelectorParserInputInterface $input): Composite { - $expressions = [$this->expression($input)]; - - while ($input->current() !== null && in_array($input->current(), ['&', '|', '-'])) { - $operator = match ($input->current()) { - '&' => Operator::And, - '|' => Operator::Or, - '-' => Operator::Not, - }; - - $input->next(); - - $expressions[] = $this->expression($input, $operator); - } - - return new Composite($expressions); - } - - protected function expression(InjectionSelectorParserInputInterface $input, Operator $operator = Operator::None): Expression - { - $negated = false; + $conjunctions = [$this->conjunction($input)]; - if ($input->current() === '-') { - $negated = true; + while ($input->current() === '|') { $input->next(); + $conjunctions[] = $this->conjunction($input); } - if (in_array($input->current(), ['L', 'R']) && $input->peek() === ':') { - $child = $this->filter($input); - } elseif ($input->current() === '(') { - $child = $this->group($input); - } else { - $child = $this->path($input); + if (count($conjunctions) === 1) { + return new Composite($conjunctions[0]); } - return new Expression($child, $operator, $negated); - } - - protected function filter(InjectionSelectorParserInputInterface $input): Filter - { - $prefix = match ($input->current()) { - 'L' => Prefix::Left, - 'R' => Prefix::Right, - default => throw new UnreachableException('Unrecognised prefix in filter: '.$input->current()), - }; + return new Composite(array_map(function (array $expressions, int $index) { + $operator = $index === 0 ? Operator::None : Operator::Or; - $input->next(); - $input->next(); - - if ($input->current() === '(') { - $child = $this->group($input); - } else { - $child = $this->path($input); - } + if (count($expressions) === 1) { + return new Expression($expressions[0]->child, $operator, $expressions[0]->negated); + } - return new Filter($child, $prefix); + return new Expression(new Group(new Selector([new Composite($expressions)])), $operator); + }, $conjunctions, array_keys($conjunctions))); } - protected function group(InjectionSelectorParserInputInterface $input): Group + /** + * @return list + */ + protected function conjunction(InjectionSelectorParserInputInterface $input): array { - if ($input->current() !== '(') { - throw new UnreachableException('Expected "(" in group.'); - } + $expressions = []; - $input->next(); + while (true) { + $operator = $expressions === [] ? Operator::None : Operator::And; + $negated = false; - $child = $this->selector($input); + if ($input->current() === '&') { + $input->next(); + } elseif ($input->current() === '-') { + $input->next(); + $expressions === [] ? $negated = true : $operator = Operator::Not; + } - if ($input->current() !== ')') { - throw new UnreachableException('Expected ")" in group.'); - } + $child = $this->operand($input); - $input->next(); + if ($child === null) { + return $expressions; + } - return new Group($child); + $expressions[] = new Expression($child, $operator, $negated); + } } - protected function path(InjectionSelectorParserInputInterface $input): Path + protected function operand(InjectionSelectorParserInputInterface $input): Filter|Group|Path|null { - $scopes = [$this->scope($input)]; + $current = $input->current(); - while ($input->current() === ' ') { - while ($input->current() === ' ') { - $input->next(); - } + if ($current === 'L:' || $current === 'R:') { + $input->next(); + $child = $this->operand($input); - $scopes[] = $this->scope($input); + return $child instanceof Filter || $child === null ? $child : new Filter($child, $current === 'L:' ? Prefix::Left : Prefix::Right); } - return new Path($scopes); - } - - protected function scope(InjectionSelectorParserInputInterface $input): Scope - { - $parts = []; + if ($current === '(') { + $input->next(); + $child = $this->selector($input); - do { - if ($input->current() === '.') { + if ($input->current() === ')') { $input->next(); } - $part = ''; + return new Group($child); + } - while ($input->current() !== null && (ctype_alpha($input->current()) || $input->current() === '*')) { - $part .= $input->current(); - $input->next(); - } + $scopes = []; - $parts[] = $part; - } while ($input->current() === '.'); + while (($current = $input->current()) !== null && preg_match('/^[\w.:]/', $current)) { + $scopes[] = Scope::fromString($current); + $input->next(); + } - return new Scope($parts); + return $scopes === [] ? null : new Path($scopes); } protected function id(): int diff --git a/src/Grammar/IncludePattern.php b/src/Grammar/IncludePattern.php index af570f4c..701b55df 100644 --- a/src/Grammar/IncludePattern.php +++ b/src/Grammar/IncludePattern.php @@ -26,9 +26,17 @@ public function getScopeName(array $captures): ?string * @return array */ public function compile(ParsedGrammar $grammar, GrammarRepositoryInterface $grammars, bool $allowA, bool $allowG): array + { + return $this->resolve($grammar, $grammars)?->compile($grammar, $grammars, $allowA, $allowG) ?? []; + } + + /** + * Resolve the pattern this include refers to, or `null` when it doesn't exist. + */ + public function resolve(ParsedGrammar $grammar, GrammarRepositoryInterface $grammars): ?PatternInterface { try { - $resolved = match (true) { + return match (true) { // "include": "$self" $this->reference === '$self' => $grammars->getFromScope($this->scopeName ?? $grammar->scopeName), // "include": "$base" @@ -41,14 +49,50 @@ public function compile(ParsedGrammar $grammar, GrammarRepositoryInterface $gram default => $grammars->getFromScope($this->scopeName), }; } catch (UnrecognisedGrammarException) { - $resolved = null; + return null; + } + } + + /** + * Whether every one of the given patterns is missing, which is how vscode-textmate decides to leave out a + * begin/end or begin/while rule: a rule whose patterns all include rules or grammars that don't exist is + * left out, and so is a list of patterns that are all missing. + * + * @param PatternInterface[] $patterns + * @param array $visiting + */ + public static function allMissing(array $patterns, ParsedGrammar $grammar, GrammarRepositoryInterface $grammars, array $visiting = []): bool + { + if ($patterns === []) { + return false; } - if ($resolved === null) { - return []; + foreach ($patterns as $pattern) { + if (! self::missing($pattern, $grammar, $grammars, $visiting)) { + return false; + } + } + + return true; + } + + /** + * @param array $visiting + */ + private static function missing(PatternInterface $pattern, ParsedGrammar $grammar, GrammarRepositoryInterface $grammars, array $visiting): bool + { + // A rule that is already being checked counts as present, as it does in vscode-textmate. + if (isset($visiting[spl_object_id($pattern)])) { + return false; } - return $resolved->compile($grammar, $grammars, $allowA, $allowG); + $visiting[spl_object_id($pattern)] = true; + + return match (true) { + $pattern instanceof IncludePattern => ($resolved = $pattern->resolve($grammar, $grammars)) === null || self::missing($resolved, $grammar, $grammars, $visiting), + $pattern instanceof CollectionPattern, $pattern instanceof ParsedGrammar, $pattern instanceof BeginEndPattern, $pattern instanceof BeginWhilePattern => self::allMissing($pattern->patterns, $grammar, $grammars, $visiting), + default => false, + }; } public function getId(): int diff --git a/src/Support/Regex.php b/src/Support/Regex.php index c4322f8a..c7a282b5 100644 --- a/src/Support/Regex.php +++ b/src/Support/Regex.php @@ -54,19 +54,24 @@ public function __construct(string $pattern) } } - public function get(bool $allowA = false, bool $allowG = false, array $references = []): string + /** + * Get the pattern to match with. For `end` and `while` patterns, pass the begin pattern's captures as + * `$references`, and back-references such as `\1` are replaced with the captured text. + */ + public function get(bool $allowA = false, bool $allowG = false, ?array $references = null): string { $pattern = $this->resolveAnchors($this->pattern, $allowA, $allowG); - $pattern = preg_replace_callback('/\\\\(\d+)/', function ($matches) use ($references) { - if (! isset($references[$matches[1]][0])) { - return ''; - } - - return $references[$matches[1]][0]; - }, $pattern); + if ($references === null) { + return $pattern; + } - return $pattern; + // The captured text is escaped, so a delimiter such as `|` or `*` matches literally. + return preg_replace_callback('/\\\\(\d+)/', fn (array $matches) => preg_replace( + '/[\-\\\\{}*+?|^$.,\[\]()#\s]/u', + '\\\\$0', + $references[$matches[1]][0] ?? '', + ), $pattern); } private function buildAnchorCache(): array diff --git a/src/Support/Str.php b/src/Support/Str.php index 6858349e..0271001a 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -53,7 +53,8 @@ public static function dotCount(string $subject): int public static function replaceScopeNameCapture(string $scopeName, array $captures): string { return preg_replace_callback(self::CAPTURING_REGEX_SOURCE, function (array $matches) use ($captures) { - $capture = $captures[intval($matches[1])]; + // `$n` captures its number in the first group and `${n:/downcase}` in the second. + $capture = $captures[intval($matches[1] !== '' ? $matches[1] : $matches[2])] ?? null; if (! $capture) { return $matches[0]; diff --git a/src/TextMate/Engines/OnigurumaEngine.php b/src/TextMate/Engines/OnigurumaEngine.php index 11ea17b4..e274b46b 100644 --- a/src/TextMate/Engines/OnigurumaEngine.php +++ b/src/TextMate/Engines/OnigurumaEngine.php @@ -34,7 +34,6 @@ public static function isSupported(): bool public function findNextMatch(array $patterns, string $lineText, int $linePos): ?MatchedPattern { $bestLocation = null; - $bestLength = null; $bestMatches = null; $bestPattern = null; @@ -53,12 +52,11 @@ public function findNextMatch(array $patterns, string $lineText, int $linePos): continue; } - [$start, $length] = $result; + [$start] = $result; if ($start === $linePos) { $bestLocation = $start; $bestMatches = mb_ereg_search_getregs(); - $bestLength = $length; $bestPattern = $pattern; break; @@ -66,7 +64,6 @@ public function findNextMatch(array $patterns, string $lineText, int $linePos): if ($start < $bestLocation || $bestLocation === null) { $bestLocation = $start; - $bestLength = $length; $bestMatches = mb_ereg_search_getregs(); $bestPattern = $pattern; @@ -78,11 +75,11 @@ public function findNextMatch(array $patterns, string $lineText, int $linePos): return null; } - // Since we know the start position and length of the match, we can - // extract the relevant portion of the input string to reduce the - // search grid for subsequent matches. - $substr = mb_substr($lineText, $bestLocation, $bestLength); - $substrLength = mb_strlen($substr); + // mbregex reports byte offsets but not where each capture group starts, so we search for the + // captures in the line from the start of the match. Captures inside a lookahead can end up + // after the match, so the search covers the rest of the line. + $substr = substr($lineText, $bestLocation); + $substrLength = strlen($substr); $keyToIndexMap = array_flip(array_keys($bestMatches)); $wellFormedMatches = []; $previousStart = 0; @@ -100,7 +97,7 @@ public function findNextMatch(array $patterns, string $lineText, int $linePos): // If the capture group is empty, we need to use the same format as PCRE's PREG_OFFSET_CAPTURE, // which is an array with an empty match and -1 as the offset. - if (! $match) { + if ($match === false || $match === '') { $wellFormedMatches[$key] = ['', -1]; continue; @@ -112,12 +109,12 @@ public function findNextMatch(array $patterns, string $lineText, int $linePos): // a cursor instead of from the start keeps a capture that repeats earlier text - // the closing delimiter of `(\*)([^*]+)(\*)`, for example - from resolving to the // position of the opening one. - $pos = mb_strpos($substr, $match, min($previousStart, $substrLength)); + $pos = strpos($substr, $match, min($previousStart, $substrLength)); // A candidate starting exactly where the previous capture did, but longer than it, // cannot be nested inside it, so the real match has to be further along. - if ($pos === $previousStart && mb_strlen($match) > $previousEnd - $previousStart) { - $sibling = mb_strpos($substr, $match, min($previousEnd, $substrLength)); + if ($pos === $previousStart && strlen($match) > $previousEnd - $previousStart) { + $sibling = strpos($substr, $match, min($previousEnd, $substrLength)); if ($sibling !== false) { $pos = $sibling; @@ -125,11 +122,11 @@ public function findNextMatch(array $patterns, string $lineText, int $linePos): } if ($pos === false) { - $pos = (int) mb_strpos($substr, $match); + $pos = (int) strpos($substr, $match); } $previousStart = $pos; - $previousEnd = max($previousEnd, $pos + mb_strlen($match)); + $previousEnd = max($previousEnd, $pos + strlen($match)); // We can then store the value in the matches array with the adjusted position. $wellFormedMatches[$key] = [$match, $bestLocation + $pos]; diff --git a/src/TextMate/PatternSearcher.php b/src/TextMate/PatternSearcher.php index 68599e79..160a52a6 100644 --- a/src/TextMate/PatternSearcher.php +++ b/src/TextMate/PatternSearcher.php @@ -30,7 +30,7 @@ public function findNextMatch(string $lineText, int $linePos, bool $while = fals { $patterns = $while && $this->pattern instanceof WhilePattern ? [ - [$this->pattern, $this->pattern->while->get($this->allowA, $this->allowG)], + [$this->pattern, $this->pattern->while->get($this->allowA, $this->allowG, $this->pattern->begin->matches)], ] : $this->pattern->compile($this->grammar, $this->grammars, $this->allowA, $this->allowG); return $this->engine->findNextMatch($patterns, $lineText, $linePos); diff --git a/src/TextMate/Tokenizer.php b/src/TextMate/Tokenizer.php index ad8b9424..f2ccf9f4 100644 --- a/src/TextMate/Tokenizer.php +++ b/src/TextMate/Tokenizer.php @@ -232,7 +232,7 @@ protected function handleCaptures(ParsedGrammar $grammar, string $lineText, bool continue; } - if ((strlen($match[0]) + $match[1]) > $maxEnd) { + if ($match[1] > $maxEnd) { break; } @@ -254,7 +254,7 @@ protected function handleCaptures(ParsedGrammar $grammar, string $lineText, bool $scopeName = $captureRule->getScopeName($matches); $nameScopesList = $stack->contentNameScopesList->push($scopeName); $stackClone = $stack->push($captureRule->pattern, $match[1], -1, false, null, $nameScopesList, $nameScopesList); - $this->tokenizeString($grammar, mb_substr($lineText, 0, strlen($match[0]) + $match[1]), $isFirstLine && $match[1] === 0, $match[1], $stackClone, $lineTokens, false); + $this->tokenizeString($grammar, substr($lineText, 0, strlen($match[0]) + $match[1]), $isFirstLine && $match[1] === 0, $match[1], $stackClone, $lineTokens, false); continue; } diff --git a/tests/Unit/InjectionParserTest.php b/tests/Unit/InjectionParserTest.php index 0252fee6..730d2dc3 100644 --- a/tests/Unit/InjectionParserTest.php +++ b/tests/Unit/InjectionParserTest.php @@ -160,6 +160,17 @@ expect($second->operator)->toBe(Operator::Or); expect($second->child->scopes[0]->__toString())->toBe('meta.tag'); }); + + it('matches scopes the same way as vscode-textmate', function (string $selector, array $scopes, bool $expected) { + expect(injection($selector)->matches($scopes))->toBe($expected); + })->with([ + 'neighbouring groups must all match' => ['L:(meta.a | meta.b) (meta.c | meta.d) - (meta source)', ['source.x', 'meta.b', 'meta.c'], true], + 'neighbouring groups when one does not match' => ['L:(meta.a | meta.b) (meta.c | meta.d) - (meta source)', ['source.x', 'meta.b', 'meta.e'], false], + 'neighbouring groups with an excluded scope' => ['L:(meta.a | meta.b) (meta.c | meta.d) - (meta source)', ['source.x', 'meta.b', 'meta.c', 'meta.embedded', 'source.js'], false], + 'a hyphen inside a scope name' => ['text.html.vue-html - comment', ['text.html.vue-html'], true], + 'a hyphen inside a scope name is not an exclusion' => ['text.html.vue-html - comment', ['text.html.vue'], false], + 'an exclusion binds more tightly than an or' => ['meta.a | meta.b - meta.c', ['meta.a', 'meta.c'], true], + ]); }); function injection(string $selector): Injection diff --git a/tests/Unit/TokenizerTest.php b/tests/Unit/TokenizerTest.php index f3d3215f..19a824bc 100644 --- a/tests/Unit/TokenizerTest.php +++ b/tests/Unit/TokenizerTest.php @@ -1,5 +1,9 @@ markTestSkipped('mbregex is not available'); + } + + $lines = array_map(function (array $line) { + $merged = []; + + foreach ($line as $token) { + $text = rtrim($token->text, "\n"); + $scopes = implode(' ', array_slice($token->scopes, 1)); + + if ($text === '') { + continue; + } + + if ($merged !== [] && $merged[count($merged) - 1][1] === $scopes) { + $merged[count($merged) - 1][0] .= $text; + } else { + $merged[] = [$text, $scopes]; + } + } + + return $merged; + }, (new Phiki)->engine(new $engine)->codeToTokens($code, ParsedGrammar::fromArray($grammar + ['scopeName' => 'source.test']))); + + expect($lines)->toBe($expected); + })->with([ + 'a rule repository is searched before the grammar repository' => [ + [ + 'patterns' => [['patterns' => [['include' => '#word']], 'repository' => ['word' => ['match' => 'a', 'name' => 'inner.test']]]], + 'repository' => ['word' => ['match' => 'a', 'name' => 'outer.test']], + ], + 'a', + [[['a', 'inner.test']]], + ], + 'applyEndPatternLast lets nested patterns win a tie with the end pattern' => [ + ['patterns' => [['begin' => 'x', 'end' => 'b', 'name' => 'region.test', 'applyEndPatternLast' => 1, 'patterns' => [['match' => 'b', 'name' => 'nested.test']]]]], + 'xb', + [[['x', 'region.test'], ['b', 'region.test nested.test']]], + ], + 'back-references in a match pattern refer to its own groups' => [ + ['patterns' => [['match' => '(a)\\1', 'name' => 'double.test']]], + 'ab', + [[['ab', '']]], + ], + 'back-references in an end pattern match the begin text literally' => [ + ['patterns' => [['begin' => '(\\|)', 'end' => '\\1', 'name' => 'region.test']]], + '|x|y', + [[['|x|', 'region.test'], ['y', '']]], + ], + 'back-references in a while pattern refer to the begin captures' => [ + ['patterns' => [['begin' => '^(\\w+):', 'while' => '^\\1 ', 'name' => 'block.test']]], + "ab: x\nab y\na z", + [[['ab: x', 'block.test']], [['ab y', 'block.test']], [['a z', '']]], + ], + 'scope names can transform a capture other than the first' => [ + ['patterns' => [['match' => '(a)(B)', 'name' => 'x.${2:/downcase}.test']]], + 'aB', + [[['aB', 'x.b.test']]], + ], + 'captures after multibyte text are retokenized within the capture' => [ + ['patterns' => [['match' => '(é)(x)', 'captures' => ['2' => ['patterns' => [['match' => 'x+', 'name' => 'inner.test']]]]]]], + 'éxx', + [[['é', ''], ['x', 'inner.test'], ['x', '']]], + ], + 'a begin/end rule whose patterns are all missing is left out' => [ + ['patterns' => [['begin' => '<', 'end' => '>', 'name' => 'region.test', 'patterns' => [['include' => 'source.missing']]]]], + '', + [[['', '']]], + ], + 'an empty or missing end never matches' => [ + ['patterns' => [['begin' => 'a', 'end' => '', 'name' => 'region.test', 'patterns' => [['match' => 'b', 'name' => 'b.test']]]]], + "ab\nb", + [[['a', 'region.test'], ['b', 'region.test b.test']], [['b', 'region.test b.test']]], + ], + 'empty names and missing captures add no scope' => [ + ['patterns' => [['match' => '(a)(b)', 'name' => '', 'captures' => ['1' => null, '2' => ['name' => '']]]]], + 'ab', + [[['ab', '']]], + ], + 'begin/while captures after a gap are applied' => [ + ['patterns' => [['begin' => '(x)(y)', 'beginCaptures' => ['2' => ['name' => 'y.test']], 'while' => 'x', 'name' => 'block.test']]], + 'xy', + [[['x', 'block.test'], ['y', 'block.test y.test']]], + ], + 'a capture in a lookahead is scoped past the end of the match' => [ + ['patterns' => [['match' => 'a(?=(b))', 'captures' => ['1' => ['name' => 'ahead.test']]]]], + 'ab', + [[['a', ''], ['b', 'ahead.test']]], + ], + ])->with([ + 'oniguruma' => OnigurumaEngine::class, + 'pcre' => PcreEngine::class, + ]); +});