Commit 1e04f06
Update grammar to cover array spreads, variant type spreads and newer operators. (#267)
* feat: add ReScript 12 operator support
Add parser support for the ReScript 12 operator improvements that were
missing from the grammar.
This covers modulo, bitwise operators, and shift operators, and adds
corpus and highlight updates for the new syntax. Unrelated untracked
files are left out of the commit.
* feat: add variant spread syntax support
Add grammar support for variant type spreads and variant pattern
spreads.
This adds corpus coverage for type declarations and expressions,
including a dedicated variant pattern spread example.
Also ignore local uv lockfiles via .git/info/exclude.
* feat: add array spread expression support
Allow spread elements in array expressions.
Add corpus coverage for array spread syntax using the ReScript 11.1
style example, including multiple spreads in the same array literal.
* fix: make extensible type "= .." a dedicated node
The ".." token for extensible variants (e.g. `type t = ..`) was
included as a choice in the `_type_identifier` rule alongside
`type_identifier` and `type_identifier_path`. Because
`_type_identifier` is inlined, the tokenizer would see the three-dot
spread operator "..." and greedily match ".." first, leaving a stray
"." behind. This made every variant type spread (`| ...Foo.t`)
produce an ERROR node, breaking font-lock for the rest of the file.
Extensible variants are syntactically distinct: `type t = ..` is the
only valid use of ".." in a type position — it cannot appear inside
generics (`option<..>` is invalid) or be combined with other type
constructors. Modelling it as a separate `extensible_type` node
branching directly from `type_binding` reflects this and removes the
ambiguity from the tokenizer entirely.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: avoid highlighting extension prefixes as operators
Remove '%' from the unconditional operator query so leading percent signs in
extension expressions like %foo and %%foo are not highlighted as operators.
Highlight '%' only in binary_expression, matching how other context-sensitive
operators such as '<', '>', and '/' are handled.
* chore: align tree-sitter CLI version in package and CI
Pin the GitHub Actions tree-sitter CLI to v0.26.3 so parser generation
matches the version declared in the package metadata, and regenerate
src/parser.c with that version.
Keep the runtime tree-sitter peer dependency at ^0.21.1. The CLI and the
runtime are versioned separately, so the CI toolchain update should not raise
the consumer runtime requirement.
Include package.json, package-lock.json, and .nvmrc in the CI path filters so
toolchain-only changes still trigger the workflow.
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 43c2f1f commit 1e04f06
8 files changed
Lines changed: 139813 additions & 115534 deletions
File tree
- .github/workflows
- queries
- src
- test/corpus
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
19 | 25 | | |
20 | 26 | | |
21 | 27 | | |
| |||
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
| 45 | + | |
| 46 | + | |
39 | 47 | | |
40 | 48 | | |
41 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
250 | 254 | | |
251 | 255 | | |
252 | 256 | | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
260 | 267 | | |
| 268 | + | |
261 | 269 | | |
262 | | - | |
263 | 270 | | |
264 | 271 | | |
265 | 272 | | |
266 | 273 | | |
| 274 | + | |
| 275 | + | |
267 | 276 | | |
268 | 277 | | |
269 | 278 | | |
| |||
305 | 314 | | |
306 | 315 | | |
307 | 316 | | |
308 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
309 | 320 | | |
310 | 321 | | |
311 | 322 | | |
| |||
316 | 327 | | |
317 | 328 | | |
318 | 329 | | |
| 330 | + | |
| 331 | + | |
319 | 332 | | |
320 | 333 | | |
321 | 334 | | |
| |||
538 | 551 | | |
539 | 552 | | |
540 | 553 | | |
541 | | - | |
| 554 | + | |
542 | 555 | | |
543 | 556 | | |
544 | 557 | | |
| |||
576 | 589 | | |
577 | 590 | | |
578 | 591 | | |
579 | | - | |
| 592 | + | |
580 | 593 | | |
581 | 594 | | |
582 | 595 | | |
| |||
590 | 603 | | |
591 | 604 | | |
592 | 605 | | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
593 | 611 | | |
594 | 612 | | |
595 | 613 | | |
| |||
985 | 1003 | | |
986 | 1004 | | |
987 | 1005 | | |
| 1006 | + | |
988 | 1007 | | |
| 1008 | + | |
989 | 1009 | | |
| 1010 | + | |
990 | 1011 | | |
991 | 1012 | | |
992 | 1013 | | |
993 | 1014 | | |
994 | 1015 | | |
995 | 1016 | | |
996 | 1017 | | |
| 1018 | + | |
997 | 1019 | | |
998 | 1020 | | |
999 | 1021 | | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
1000 | 1025 | | |
1001 | 1026 | | |
1002 | 1027 | | |
| |||
1030 | 1055 | | |
1031 | 1056 | | |
1032 | 1057 | | |
| 1058 | + | |
1033 | 1059 | | |
1034 | 1060 | | |
1035 | 1061 | | |
| |||
1085 | 1111 | | |
1086 | 1112 | | |
1087 | 1113 | | |
1088 | | - | |
| 1114 | + | |
1089 | 1115 | | |
1090 | 1116 | | |
1091 | 1117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
228 | 231 | | |
229 | 232 | | |
230 | 233 | | |
231 | 234 | | |
232 | 235 | | |
233 | 236 | | |
234 | 237 | | |
| 238 | + | |
235 | 239 | | |
| 240 | + | |
236 | 241 | | |
| 242 | + | |
| 243 | + | |
237 | 244 | | |
238 | 245 | | |
239 | 246 | | |
| |||
245 | 252 | | |
246 | 253 | | |
247 | 254 | | |
248 | | - | |
249 | | - | |
| 255 | + | |
| 256 | + | |
250 | 257 | | |
251 | 258 | | |
252 | 259 | | |
| |||
0 commit comments