tree-sitter-ucode 0.3.0 → 0.5.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.
Files changed (53) hide show
  1. package/README.md +32 -81
  2. package/grammar.js +221 -35
  3. package/markup/grammar.js +1057 -0
  4. package/markup/queries/folds.scm +20 -0
  5. package/markup/queries/highlights.scm +38 -0
  6. package/markup/queries/indents.scm +51 -0
  7. package/markup/queries/injections.scm +40 -0
  8. package/markup/queries/locals.scm +107 -0
  9. package/markup/queries/tags.scm +65 -0
  10. package/markup/queries/textobjects.scm +56 -0
  11. package/markup/src/grammar.json +5814 -0
  12. package/markup/src/node-types.json +3224 -0
  13. package/markup/src/parser.c +134512 -0
  14. package/markup/src/scanner.c +22 -0
  15. package/package.json +9 -5
  16. package/prebuilds/darwin-arm64/tree-sitter-ucode.node +0 -0
  17. package/prebuilds/linux-arm64/tree-sitter-ucode.node +0 -0
  18. package/prebuilds/linux-x64/tree-sitter-ucode.node +0 -0
  19. package/prebuilds/win32-x64/tree-sitter-ucode.node +0 -0
  20. package/queries/locals.scm +8 -0
  21. package/queries/tags.scm +15 -2
  22. package/scripts/generate-markup-grammar.js +93 -0
  23. package/src/grammar.json +1104 -233
  24. package/src/node-types.json +736 -69
  25. package/src/parser.c +106697 -25362
  26. package/src/scanner.c +16 -193
  27. package/src/scanner_impl.h +494 -0
  28. package/tree-sitter-ucode.wasm +0 -0
  29. package/tree-sitter-ucode_markup.wasm +0 -0
  30. package/tree-sitter.json +46 -22
  31. package/ucdocs/grammar.js +284 -0
  32. package/ucdocs/queries/highlights.scm +25 -0
  33. package/ucdocs/queries/tags.scm +22 -0
  34. package/ucdocs/src/grammar.json +1437 -0
  35. package/ucdocs/src/node-types.json +1347 -0
  36. package/ucdocs/src/parser.c +6387 -0
  37. package/ucdocs/src/tree_sitter/alloc.h +54 -0
  38. package/ucdocs/src/tree_sitter/array.h +330 -0
  39. package/ucdocs/src/tree_sitter/parser.h +286 -0
  40. package/tmpl/grammar.js +0 -68
  41. package/tmpl/queries/folds.scm +0 -4
  42. package/tmpl/queries/highlights.scm +0 -23
  43. package/tmpl/queries/indents.scm +0 -5
  44. package/tmpl/queries/injections.scm +0 -8
  45. package/tmpl/queries/locals.scm +0 -3
  46. package/tmpl/src/grammar.json +0 -251
  47. package/tmpl/src/node-types.json +0 -238
  48. package/tmpl/src/parser.c +0 -724
  49. package/tmpl/src/scanner.c +0 -174
  50. package/tree-sitter-ucode_tmpl.wasm +0 -0
  51. /package/{tmpl → markup}/src/tree_sitter/alloc.h +0 -0
  52. /package/{tmpl → markup}/src/tree_sitter/array.h +0 -0
  53. /package/{tmpl → markup}/src/tree_sitter/parser.h +0 -0
package/tmpl/grammar.js DELETED
@@ -1,68 +0,0 @@
1
- /**
2
- * @file Ucode template grammar for tree-sitter
3
- * @license MIT
4
- *
5
- * Handles .uc.tmpl / .utpl files: raw text interspersed with ucode code
6
- * blocks ({%...%}), expression blocks ({{...}}), and comments ({#...#}).
7
- *
8
- * The grammar captures raw text verbatim and the inner content of code /
9
- * expression blocks as opaque `code` nodes. Editors use language injection
10
- * (see tmpl/queries/injections.scm) to parse those nodes as ucode.
11
- *
12
- * Whitespace-stripping markers are supported on both openers and closers:
13
- *
14
- * Opener variants Closer variants
15
- * ───────────── ──────────────
16
- * {% {%- {%+ %} -%} (statement)
17
- * {{ {{- }} -}} (expression)
18
- * {# {#- #} -#} (comment)
19
- *
20
- * {%- strips trailing whitespace from the preceding raw-text block.
21
- * -%} strips leading whitespace from the following raw-text block.
22
- * {%+ suppresses stripping even when lstrip_blocks is configured.
23
- */
24
-
25
- /// <reference types="tree-sitter-cli/dsl" />
26
- // @ts-check
27
-
28
- module.exports = grammar({
29
- name: 'ucode_tmpl',
30
-
31
- externals: $ => [
32
- $._raw_text, // literal text outside any tag
33
- $._stmt_code, // content between {% ... %} (before the closer)
34
- $._expr_code, // content between {{ ... }} (before the closer)
35
- $._comment_body, // content between {# ... #} (before the closer)
36
- $.eof_close, // emitted at EOF when inside a statement tag (implicit close)
37
- ],
38
-
39
- // The template scanner handles all whitespace explicitly; no implicit extras.
40
- extras: _ => [],
41
-
42
- rules: {
43
- document: $ => repeat(choice(
44
- alias($._raw_text, $.raw_text),
45
- $.statement_tag,
46
- $.expression_tag,
47
- $.comment_tag,
48
- )),
49
-
50
- statement_tag: $ => seq(
51
- field('open', choice('{%-', '{%+', '{%')),
52
- field('code', optional(alias($._stmt_code, $.code))),
53
- field('close', choice('-%}', '%}', $.eof_close)),
54
- ),
55
-
56
- expression_tag: $ => seq(
57
- field('open', choice('{{-', '{{')),
58
- field('code', optional(alias($._expr_code, $.code))),
59
- field('close', choice('-}}', '}}')),
60
- ),
61
-
62
- comment_tag: $ => seq(
63
- field('open', choice('{#-', '{#')),
64
- field('content', optional(alias($._comment_body, $.comment_content))),
65
- field('close', choice('-#}', '#}')),
66
- ),
67
- },
68
- });
@@ -1,4 +0,0 @@
1
- ; Fold queries for ucode_tmpl.
2
- ; Folds are not meaningful at the template document level since each tag is
3
- ; typically one or a few lines. Folding inside code blocks is handled by the
4
- ; injected ucode grammar.
@@ -1,23 +0,0 @@
1
- ; Highlight queries for ucode_tmpl.
2
- ; Template structure is styled here; ucode code inside tags is highlighted
3
- ; via language injection (see injections.scm).
4
-
5
- ; -------------------------------------------------------------------------
6
- ; Tag delimiters
7
- ; -------------------------------------------------------------------------
8
-
9
- [
10
- "{%" "%}"
11
- "{%-" "-%}"
12
- "{%+"
13
- "{{" "}}"
14
- "{{-" "-}}"
15
- "{#" "#}"
16
- "{#-" "-#}"
17
- ] @keyword
18
-
19
- ; -------------------------------------------------------------------------
20
- ; Template comments
21
- ; -------------------------------------------------------------------------
22
-
23
- (comment_tag) @comment @spell
@@ -1,5 +0,0 @@
1
- ; Indentation queries for ucode_tmpl.
2
- ; Raw text between tags is not indented by the template engine, so there are
3
- ; no template-level indent rules. Code inside statement_tag and expression_tag
4
- ; is parsed via language injection (see injections.scm) and indented according
5
- ; to the injected ucode grammar's indents.scm.
@@ -1,8 +0,0 @@
1
- ; Injection queries for ucode_tmpl.
2
- ; Instructs editors to parse code/expression block content as ucode.
3
-
4
- ((statement_tag (code) @injection.content)
5
- (#set! injection.language "ucode"))
6
-
7
- ((expression_tag (code) @injection.content)
8
- (#set! injection.language "ucode"))
@@ -1,3 +0,0 @@
1
- ; Locals queries for ucode_tmpl.
2
- ; Variable definitions and references inside code blocks are handled by
3
- ; the injected ucode grammar; nothing additional is needed here.
@@ -1,251 +0,0 @@
1
- {
2
- "$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json",
3
- "name": "ucode_tmpl",
4
- "rules": {
5
- "document": {
6
- "type": "REPEAT",
7
- "content": {
8
- "type": "CHOICE",
9
- "members": [
10
- {
11
- "type": "ALIAS",
12
- "content": {
13
- "type": "SYMBOL",
14
- "name": "_raw_text"
15
- },
16
- "named": true,
17
- "value": "raw_text"
18
- },
19
- {
20
- "type": "SYMBOL",
21
- "name": "statement_tag"
22
- },
23
- {
24
- "type": "SYMBOL",
25
- "name": "expression_tag"
26
- },
27
- {
28
- "type": "SYMBOL",
29
- "name": "comment_tag"
30
- }
31
- ]
32
- }
33
- },
34
- "statement_tag": {
35
- "type": "SEQ",
36
- "members": [
37
- {
38
- "type": "FIELD",
39
- "name": "open",
40
- "content": {
41
- "type": "CHOICE",
42
- "members": [
43
- {
44
- "type": "STRING",
45
- "value": "{%-"
46
- },
47
- {
48
- "type": "STRING",
49
- "value": "{%+"
50
- },
51
- {
52
- "type": "STRING",
53
- "value": "{%"
54
- }
55
- ]
56
- }
57
- },
58
- {
59
- "type": "FIELD",
60
- "name": "code",
61
- "content": {
62
- "type": "CHOICE",
63
- "members": [
64
- {
65
- "type": "ALIAS",
66
- "content": {
67
- "type": "SYMBOL",
68
- "name": "_stmt_code"
69
- },
70
- "named": true,
71
- "value": "code"
72
- },
73
- {
74
- "type": "BLANK"
75
- }
76
- ]
77
- }
78
- },
79
- {
80
- "type": "FIELD",
81
- "name": "close",
82
- "content": {
83
- "type": "CHOICE",
84
- "members": [
85
- {
86
- "type": "STRING",
87
- "value": "-%}"
88
- },
89
- {
90
- "type": "STRING",
91
- "value": "%}"
92
- },
93
- {
94
- "type": "SYMBOL",
95
- "name": "eof_close"
96
- }
97
- ]
98
- }
99
- }
100
- ]
101
- },
102
- "expression_tag": {
103
- "type": "SEQ",
104
- "members": [
105
- {
106
- "type": "FIELD",
107
- "name": "open",
108
- "content": {
109
- "type": "CHOICE",
110
- "members": [
111
- {
112
- "type": "STRING",
113
- "value": "{{-"
114
- },
115
- {
116
- "type": "STRING",
117
- "value": "{{"
118
- }
119
- ]
120
- }
121
- },
122
- {
123
- "type": "FIELD",
124
- "name": "code",
125
- "content": {
126
- "type": "CHOICE",
127
- "members": [
128
- {
129
- "type": "ALIAS",
130
- "content": {
131
- "type": "SYMBOL",
132
- "name": "_expr_code"
133
- },
134
- "named": true,
135
- "value": "code"
136
- },
137
- {
138
- "type": "BLANK"
139
- }
140
- ]
141
- }
142
- },
143
- {
144
- "type": "FIELD",
145
- "name": "close",
146
- "content": {
147
- "type": "CHOICE",
148
- "members": [
149
- {
150
- "type": "STRING",
151
- "value": "-}}"
152
- },
153
- {
154
- "type": "STRING",
155
- "value": "}}"
156
- }
157
- ]
158
- }
159
- }
160
- ]
161
- },
162
- "comment_tag": {
163
- "type": "SEQ",
164
- "members": [
165
- {
166
- "type": "FIELD",
167
- "name": "open",
168
- "content": {
169
- "type": "CHOICE",
170
- "members": [
171
- {
172
- "type": "STRING",
173
- "value": "{#-"
174
- },
175
- {
176
- "type": "STRING",
177
- "value": "{#"
178
- }
179
- ]
180
- }
181
- },
182
- {
183
- "type": "FIELD",
184
- "name": "content",
185
- "content": {
186
- "type": "CHOICE",
187
- "members": [
188
- {
189
- "type": "ALIAS",
190
- "content": {
191
- "type": "SYMBOL",
192
- "name": "_comment_body"
193
- },
194
- "named": true,
195
- "value": "comment_content"
196
- },
197
- {
198
- "type": "BLANK"
199
- }
200
- ]
201
- }
202
- },
203
- {
204
- "type": "FIELD",
205
- "name": "close",
206
- "content": {
207
- "type": "CHOICE",
208
- "members": [
209
- {
210
- "type": "STRING",
211
- "value": "-#}"
212
- },
213
- {
214
- "type": "STRING",
215
- "value": "#}"
216
- }
217
- ]
218
- }
219
- }
220
- ]
221
- }
222
- },
223
- "extras": [],
224
- "conflicts": [],
225
- "precedences": [],
226
- "externals": [
227
- {
228
- "type": "SYMBOL",
229
- "name": "_raw_text"
230
- },
231
- {
232
- "type": "SYMBOL",
233
- "name": "_stmt_code"
234
- },
235
- {
236
- "type": "SYMBOL",
237
- "name": "_expr_code"
238
- },
239
- {
240
- "type": "SYMBOL",
241
- "name": "_comment_body"
242
- },
243
- {
244
- "type": "SYMBOL",
245
- "name": "eof_close"
246
- }
247
- ],
248
- "inline": [],
249
- "supertypes": [],
250
- "reserved": {}
251
- }
@@ -1,238 +0,0 @@
1
- [
2
- {
3
- "type": "comment_tag",
4
- "named": true,
5
- "fields": {
6
- "close": {
7
- "multiple": false,
8
- "required": true,
9
- "types": [
10
- {
11
- "type": "#}",
12
- "named": false
13
- },
14
- {
15
- "type": "-#}",
16
- "named": false
17
- }
18
- ]
19
- },
20
- "content": {
21
- "multiple": false,
22
- "required": false,
23
- "types": [
24
- {
25
- "type": "comment_content",
26
- "named": true
27
- }
28
- ]
29
- },
30
- "open": {
31
- "multiple": false,
32
- "required": true,
33
- "types": [
34
- {
35
- "type": "{#",
36
- "named": false
37
- },
38
- {
39
- "type": "{#-",
40
- "named": false
41
- }
42
- ]
43
- }
44
- }
45
- },
46
- {
47
- "type": "document",
48
- "named": true,
49
- "root": true,
50
- "fields": {},
51
- "children": {
52
- "multiple": true,
53
- "required": false,
54
- "types": [
55
- {
56
- "type": "comment_tag",
57
- "named": true
58
- },
59
- {
60
- "type": "expression_tag",
61
- "named": true
62
- },
63
- {
64
- "type": "raw_text",
65
- "named": true
66
- },
67
- {
68
- "type": "statement_tag",
69
- "named": true
70
- }
71
- ]
72
- }
73
- },
74
- {
75
- "type": "expression_tag",
76
- "named": true,
77
- "fields": {
78
- "close": {
79
- "multiple": false,
80
- "required": true,
81
- "types": [
82
- {
83
- "type": "-}}",
84
- "named": false
85
- },
86
- {
87
- "type": "}}",
88
- "named": false
89
- }
90
- ]
91
- },
92
- "code": {
93
- "multiple": false,
94
- "required": false,
95
- "types": [
96
- {
97
- "type": "code",
98
- "named": true
99
- }
100
- ]
101
- },
102
- "open": {
103
- "multiple": false,
104
- "required": true,
105
- "types": [
106
- {
107
- "type": "{{",
108
- "named": false
109
- },
110
- {
111
- "type": "{{-",
112
- "named": false
113
- }
114
- ]
115
- }
116
- }
117
- },
118
- {
119
- "type": "statement_tag",
120
- "named": true,
121
- "fields": {
122
- "close": {
123
- "multiple": false,
124
- "required": true,
125
- "types": [
126
- {
127
- "type": "%}",
128
- "named": false
129
- },
130
- {
131
- "type": "-%}",
132
- "named": false
133
- },
134
- {
135
- "type": "eof_close",
136
- "named": true
137
- }
138
- ]
139
- },
140
- "code": {
141
- "multiple": false,
142
- "required": false,
143
- "types": [
144
- {
145
- "type": "code",
146
- "named": true
147
- }
148
- ]
149
- },
150
- "open": {
151
- "multiple": false,
152
- "required": true,
153
- "types": [
154
- {
155
- "type": "{%",
156
- "named": false
157
- },
158
- {
159
- "type": "{%+",
160
- "named": false
161
- },
162
- {
163
- "type": "{%-",
164
- "named": false
165
- }
166
- ]
167
- }
168
- }
169
- },
170
- {
171
- "type": "#}",
172
- "named": false
173
- },
174
- {
175
- "type": "%}",
176
- "named": false
177
- },
178
- {
179
- "type": "-#}",
180
- "named": false
181
- },
182
- {
183
- "type": "-%}",
184
- "named": false
185
- },
186
- {
187
- "type": "-}}",
188
- "named": false
189
- },
190
- {
191
- "type": "code",
192
- "named": true
193
- },
194
- {
195
- "type": "comment_content",
196
- "named": true
197
- },
198
- {
199
- "type": "eof_close",
200
- "named": true
201
- },
202
- {
203
- "type": "raw_text",
204
- "named": true
205
- },
206
- {
207
- "type": "{#",
208
- "named": false
209
- },
210
- {
211
- "type": "{#-",
212
- "named": false
213
- },
214
- {
215
- "type": "{%",
216
- "named": false
217
- },
218
- {
219
- "type": "{%+",
220
- "named": false
221
- },
222
- {
223
- "type": "{%-",
224
- "named": false
225
- },
226
- {
227
- "type": "{{",
228
- "named": false
229
- },
230
- {
231
- "type": "{{-",
232
- "named": false
233
- },
234
- {
235
- "type": "}}",
236
- "named": false
237
- }
238
- ]