@marko/tree-sitter 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/grammar.js +2 -0
- package/package.json +14 -14
- package/prebuilds/darwin-arm64/@marko+tree-sitter.node +0 -0
- package/prebuilds/darwin-x64/@marko+tree-sitter.node +0 -0
- package/prebuilds/linux-arm64/@marko+tree-sitter.node +0 -0
- package/prebuilds/linux-x64/@marko+tree-sitter.node +0 -0
- package/prebuilds/win32-x64/@marko+tree-sitter.node +0 -0
- package/src/grammar.json +8 -0
- package/src/node-types.json +12 -0
- package/src/parser.c +2151 -2050
- package/src/scanner.c +163 -2
- package/tree-sitter-marko.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -40,9 +40,9 @@ parser.setLanguage(Marko);
|
|
|
40
40
|
Building from a checkout:
|
|
41
41
|
|
|
42
42
|
```sh
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
pnpm install
|
|
44
|
+
pnpm run build # tree-sitter generate && node-gyp rebuild
|
|
45
|
+
pnpm run build:wasm # tree-sitter-marko.wasm (the CLI fetches wasi-sdk itself)
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
For editors, the grammar ships ready-to-use queries: `queries/highlights.scm`
|
|
@@ -61,9 +61,9 @@ in the host tool like any other language.
|
|
|
61
61
|
From this directory:
|
|
62
62
|
|
|
63
63
|
```sh
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
pnpm exec tree-sitter playground # interactive tree in the browser
|
|
65
|
+
pnpm exec tree-sitter parse file.marko # print the syntax tree
|
|
66
|
+
pnpm exec tree-sitter highlight file.marko # ANSI highlighting (--html for a page)
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
`highlight` resolves the injected languages through the CLI config: run
|
|
@@ -82,7 +82,7 @@ and start treesitter for the filetype:
|
|
|
82
82
|
```sh
|
|
83
83
|
# from this directory
|
|
84
84
|
mkdir -p ~/.local/share/nvim/site/parser ~/.local/share/nvim/site/queries
|
|
85
|
-
|
|
85
|
+
pnpm exec tree-sitter build -o ~/.local/share/nvim/site/parser/marko.so
|
|
86
86
|
cp -R queries ~/.local/share/nvim/site/queries/marko
|
|
87
87
|
```
|
|
88
88
|
|
|
@@ -262,7 +262,7 @@ split without lookahead the scanner doesn't have.
|
|
|
262
262
|
|
|
263
263
|
Marko's parser is [htmljs-parser](https://github.com/marko-js/htmljs-parser);
|
|
264
264
|
this grammar's external scanner reimplements its state machine, and the test
|
|
265
|
-
suite (`
|
|
265
|
+
suite (`pnpm test`, Node 22) asserts the tree reproduces the parser's event
|
|
266
266
|
stream with byte-precise ranges across the parser's full fixture suite, plus
|
|
267
267
|
thousands of templates from the Marko ecosystem during development.
|
|
268
268
|
|
package/grammar.js
CHANGED
|
@@ -70,6 +70,7 @@ module.exports = grammar({
|
|
|
70
70
|
$._types_close, // ">"
|
|
71
71
|
$._attr_group_open, // "[" (concise mode)
|
|
72
72
|
$._attr_group_close, // "]"
|
|
73
|
+
$.attr_method_async, // "async" before a shorthand method
|
|
73
74
|
$.attr_name,
|
|
74
75
|
$.attr_eq, // "="
|
|
75
76
|
$.attr_bound_eq, // ":="
|
|
@@ -151,6 +152,7 @@ module.exports = grammar({
|
|
|
151
152
|
$.type_args,
|
|
152
153
|
$.type_params,
|
|
153
154
|
$.attr_group,
|
|
155
|
+
$.attr_method_async,
|
|
154
156
|
$.attr_name,
|
|
155
157
|
$.attr_value,
|
|
156
158
|
$.attr_bound_value,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/tree-sitter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Tree-sitter grammar for the Marko templating language",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@types/mocha": "^10.0.6",
|
|
45
45
|
"@types/node": "^20.11.16",
|
|
46
46
|
"degit": "^2.8.4",
|
|
47
|
-
"htmljs-parser": "^5.
|
|
47
|
+
"htmljs-parser": "^5.14.0",
|
|
48
48
|
"mocha": "^10.2.0",
|
|
49
49
|
"node-gyp": "^11.0.0",
|
|
50
50
|
"prebuildify": "^6.0.1",
|
|
@@ -61,6 +61,15 @@
|
|
|
61
61
|
"optional": true
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
+
"tree-sitter": [
|
|
65
|
+
{
|
|
66
|
+
"scope": "source.marko",
|
|
67
|
+
"file-types": [
|
|
68
|
+
"marko"
|
|
69
|
+
],
|
|
70
|
+
"injection-regex": "^marko$"
|
|
71
|
+
}
|
|
72
|
+
],
|
|
64
73
|
"scripts": {
|
|
65
74
|
"build": "tree-sitter generate && node-gyp rebuild",
|
|
66
75
|
"change": "changeset add",
|
|
@@ -72,15 +81,6 @@
|
|
|
72
81
|
"prebuild": "prebuildify --napi --strip",
|
|
73
82
|
"build:wasm": "tree-sitter build --wasm -o tree-sitter-marko.wasm",
|
|
74
83
|
"test:wasm": "tsx tools/check-wasm.mts",
|
|
75
|
-
"version": "changeset version && node tools/sync-tree-sitter-version.mjs &&
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
"scope": "source.marko",
|
|
80
|
-
"file-types": [
|
|
81
|
-
"marko"
|
|
82
|
-
],
|
|
83
|
-
"injection-regex": "^marko$"
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
}
|
|
84
|
+
"version": "changeset version && node tools/sync-tree-sitter-version.mjs && pnpm install --lockfile-only"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/grammar.json
CHANGED
|
@@ -278,6 +278,10 @@
|
|
|
278
278
|
"type": "SYMBOL",
|
|
279
279
|
"name": "attr_group"
|
|
280
280
|
},
|
|
281
|
+
{
|
|
282
|
+
"type": "SYMBOL",
|
|
283
|
+
"name": "attr_method_async"
|
|
284
|
+
},
|
|
281
285
|
{
|
|
282
286
|
"type": "SYMBOL",
|
|
283
287
|
"name": "attr_name"
|
|
@@ -994,6 +998,10 @@
|
|
|
994
998
|
"type": "SYMBOL",
|
|
995
999
|
"name": "_attr_group_close"
|
|
996
1000
|
},
|
|
1001
|
+
{
|
|
1002
|
+
"type": "SYMBOL",
|
|
1003
|
+
"name": "attr_method_async"
|
|
1004
|
+
},
|
|
997
1005
|
{
|
|
998
1006
|
"type": "SYMBOL",
|
|
999
1007
|
"name": "attr_name"
|
package/src/node-types.json
CHANGED
|
@@ -69,6 +69,10 @@
|
|
|
69
69
|
"type": "attr_group_open",
|
|
70
70
|
"named": true
|
|
71
71
|
},
|
|
72
|
+
{
|
|
73
|
+
"type": "attr_method_async",
|
|
74
|
+
"named": true
|
|
75
|
+
},
|
|
72
76
|
{
|
|
73
77
|
"type": "attr_name",
|
|
74
78
|
"named": true
|
|
@@ -241,6 +245,10 @@
|
|
|
241
245
|
"type": "attr_group",
|
|
242
246
|
"named": true
|
|
243
247
|
},
|
|
248
|
+
{
|
|
249
|
+
"type": "attr_method_async",
|
|
250
|
+
"named": true
|
|
251
|
+
},
|
|
244
252
|
{
|
|
245
253
|
"type": "attr_name",
|
|
246
254
|
"named": true
|
|
@@ -749,6 +757,10 @@
|
|
|
749
757
|
"type": "attr_group_open",
|
|
750
758
|
"named": true
|
|
751
759
|
},
|
|
760
|
+
{
|
|
761
|
+
"type": "attr_method_async",
|
|
762
|
+
"named": true
|
|
763
|
+
},
|
|
752
764
|
{
|
|
753
765
|
"type": "attr_name",
|
|
754
766
|
"named": true
|