@hew-lang/tree-sitter-hew 1.0.2 → 1.1.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 +7 -0
- package/grammar.js +812 -260
- package/package.json +2 -2
- package/queries/folds.scm +2 -4
- package/queries/highlights.scm +70 -25
- package/queries/indents.scm +2 -2
- package/queries/locals.scm +8 -13
- package/src/grammar.json +5292 -2489
- package/src/node-types.json +3205 -1004
- package/src/parser.c +102163 -69645
- package/src/tree_sitter/array.h +68 -124
- package/tree-sitter.json +2 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hew-lang/tree-sitter-hew",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Hew grammar for tree-sitter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"prebuildify": "^6.0.1",
|
|
42
42
|
"tree-sitter": "^0.25.0",
|
|
43
|
-
"tree-sitter-cli": "
|
|
43
|
+
"tree-sitter-cli": "0.25.10"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"tree-sitter": "^0.25.0"
|
package/queries/folds.scm
CHANGED
|
@@ -3,21 +3,19 @@
|
|
|
3
3
|
[
|
|
4
4
|
(block)
|
|
5
5
|
(function_declaration)
|
|
6
|
-
(async_function_declaration)
|
|
7
6
|
(gen_function_declaration)
|
|
8
|
-
(async_gen_function_declaration)
|
|
9
7
|
(struct_declaration)
|
|
8
|
+
(tuple_type_declaration)
|
|
10
9
|
(enum_declaration)
|
|
11
10
|
(trait_declaration)
|
|
12
11
|
(impl_declaration)
|
|
13
12
|
(actor_declaration)
|
|
14
13
|
(supervisor_declaration)
|
|
15
|
-
(
|
|
14
|
+
(machine_declaration)
|
|
16
15
|
(extern_block)
|
|
17
16
|
(receive_function)
|
|
18
17
|
(receive_gen_function)
|
|
19
18
|
(if_expression)
|
|
20
19
|
(match_expression)
|
|
21
20
|
(select_expression)
|
|
22
|
-
(join_expression)
|
|
23
21
|
] @fold
|
package/queries/highlights.scm
CHANGED
|
@@ -2,32 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
; ---- Keywords ----
|
|
4
4
|
[
|
|
5
|
-
"fn" "let" "var" "const" "pub" "return" "if" "else" "match" "for" "while"
|
|
6
|
-
"loop" "break" "continue" "in" "spawn" "await" "select" "
|
|
7
|
-
"import" "extern" "
|
|
5
|
+
"fn" "let" "var" "const" "mut" "pub" "return" "if" "else" "match" "for" "while"
|
|
6
|
+
"loop" "break" "continue" "in" "spawn" "await" "select" "race"
|
|
7
|
+
"import" "extern" "gen" "yield" "scope" "move" "fork"
|
|
8
8
|
"type" "where" "dyn" "unsafe" "defer"
|
|
9
|
-
"init" "child" "
|
|
10
|
-
"package" "
|
|
9
|
+
"init" "child" "pool" "restart" "wired_to"
|
|
10
|
+
"package" "after"
|
|
11
11
|
"reserved" "optional" "deprecated" "default"
|
|
12
12
|
] @keyword
|
|
13
13
|
|
|
14
|
+
(select_arm "from" @keyword)
|
|
15
|
+
|
|
16
|
+
; `clone <operand>` — the eager copy-on-write cost operation (a contextual
|
|
17
|
+
; prefix operator, not a reserved word). The grammar only builds a
|
|
18
|
+
; `clone_expression` when `clone` is in prefix position, so colouring the
|
|
19
|
+
; anonymous token here never touches `x.clone()`, `fn clone()`, or `clone(args)`,
|
|
20
|
+
; where `clone` stays an ordinary identifier.
|
|
21
|
+
(clone_expression "clone" @keyword.operator)
|
|
22
|
+
(callable_capabilities ["var" "once" "clone" "suspends"] @keyword)
|
|
23
|
+
(private_capture_list "capture" @keyword)
|
|
24
|
+
(private_capture (identifier) @variable)
|
|
25
|
+
(failure_return "fails" @keyword)
|
|
26
|
+
(child_clause ["count" "stop"] @keyword)
|
|
27
|
+
|
|
14
28
|
"receive" @keyword
|
|
15
29
|
|
|
16
|
-
|
|
30
|
+
; Contextual words are coloured only where the grammar builds the node, so
|
|
31
|
+
; `consume` as a parameter or receiver modifier never touches the same
|
|
32
|
+
; spelling used as an ordinary identifier.
|
|
33
|
+
(self_parameter "consume" @keyword)
|
|
34
|
+
(parameter "consume" @keyword)
|
|
35
|
+
|
|
36
|
+
"indirect" @keyword
|
|
37
|
+
|
|
38
|
+
"as" @keyword
|
|
17
39
|
|
|
18
40
|
[
|
|
19
|
-
"enum" "trait" "impl" "actor" "supervisor" "
|
|
41
|
+
"enum" "trait" "impl" "actor" "supervisor" "machine"
|
|
20
42
|
] @keyword.type
|
|
21
43
|
|
|
22
44
|
[
|
|
23
|
-
"state" "
|
|
45
|
+
"state" "on" "when"
|
|
46
|
+
"events" "emits" "reenter" "entry" "exit" "emit" "initial"
|
|
47
|
+
"mailbox" "overflow" "strategy" "intensity" "within"
|
|
24
48
|
] @keyword
|
|
25
49
|
|
|
26
|
-
|
|
50
|
+
[
|
|
51
|
+
"block" "drop_new" "drop_old" "fail" "coalesce" "fallback"
|
|
52
|
+
] @constant.builtin
|
|
27
53
|
|
|
28
54
|
[
|
|
29
55
|
"permanent" "transient" "temporary"
|
|
30
|
-
"one_for_one" "one_for_all" "rest_for_one"
|
|
31
56
|
] @constant.builtin
|
|
32
57
|
|
|
33
58
|
; ---- Attributes ----
|
|
@@ -57,25 +82,28 @@
|
|
|
57
82
|
(line_comment) @comment
|
|
58
83
|
(block_comment) @comment
|
|
59
84
|
|
|
85
|
+
; Retired path separators, glob imports, and turbofish forms recover as parser
|
|
86
|
+
; errors. The compiler owns their diagnostic codes; this grammar highlights the
|
|
87
|
+
; error nodes it produces.
|
|
88
|
+
(ERROR) @error
|
|
89
|
+
|
|
60
90
|
; ---- Types ----
|
|
61
91
|
(primitive_type) @type.builtin
|
|
62
92
|
|
|
63
93
|
(type_parameters "<" @punctuation.bracket)
|
|
64
94
|
(type_parameters ">" @punctuation.bracket)
|
|
95
|
+
(machine_type_parameters "<" @punctuation.bracket)
|
|
96
|
+
(machine_type_parameters ">" @punctuation.bracket)
|
|
97
|
+
(const_parameter name: (identifier) @constant)
|
|
98
|
+
(associated_type_projection (identifier) @type)
|
|
65
99
|
|
|
66
100
|
; ---- Functions ----
|
|
67
101
|
(function_declaration
|
|
68
102
|
name: (identifier) @function)
|
|
69
103
|
|
|
70
|
-
(async_function_declaration
|
|
71
|
-
name: (identifier) @function)
|
|
72
|
-
|
|
73
104
|
(gen_function_declaration
|
|
74
105
|
name: (identifier) @function)
|
|
75
106
|
|
|
76
|
-
(async_gen_function_declaration
|
|
77
|
-
name: (identifier) @function)
|
|
78
|
-
|
|
79
107
|
(trait_function_signature
|
|
80
108
|
name: (identifier) @function)
|
|
81
109
|
|
|
@@ -128,10 +156,10 @@
|
|
|
128
156
|
name: (identifier) @type)
|
|
129
157
|
|
|
130
158
|
(impl_declaration
|
|
131
|
-
|
|
159
|
+
type: (identifier) @type)
|
|
132
160
|
|
|
133
161
|
(impl_declaration
|
|
134
|
-
|
|
162
|
+
self_type: (identifier) @type)
|
|
135
163
|
|
|
136
164
|
(actor_declaration
|
|
137
165
|
name: (identifier) @type)
|
|
@@ -139,27 +167,33 @@
|
|
|
139
167
|
(supervisor_declaration
|
|
140
168
|
name: (identifier) @type)
|
|
141
169
|
|
|
142
|
-
(wire_declaration
|
|
143
|
-
name: (identifier) @type)
|
|
144
|
-
|
|
145
170
|
(machine_declaration
|
|
146
171
|
name: (identifier) @type)
|
|
147
172
|
|
|
148
173
|
(machine_state
|
|
149
174
|
name: (identifier) @constant)
|
|
150
175
|
|
|
151
|
-
(
|
|
176
|
+
(machine_event_decl
|
|
152
177
|
name: (identifier) @constant)
|
|
153
178
|
|
|
154
179
|
(machine_transition
|
|
155
180
|
event: (identifier) @constant)
|
|
156
181
|
|
|
182
|
+
(emit_statement
|
|
183
|
+
event: (identifier) @constant)
|
|
184
|
+
|
|
157
185
|
(map_entry
|
|
158
186
|
key: (expression) @property)
|
|
159
187
|
|
|
160
188
|
(type_alias
|
|
161
189
|
name: (identifier) @type)
|
|
162
190
|
|
|
191
|
+
(tuple_type_declaration
|
|
192
|
+
name: (identifier) @type)
|
|
193
|
+
|
|
194
|
+
; Supervisor strategy enum values (real lexer keywords; hew-lexer lex:189-195)
|
|
195
|
+
(supervisor_strategy_value) @constant.builtin
|
|
196
|
+
|
|
163
197
|
(variant
|
|
164
198
|
name: (identifier) @constant)
|
|
165
199
|
|
|
@@ -175,6 +209,9 @@
|
|
|
175
209
|
(identifier) @type
|
|
176
210
|
(identifier) @property)
|
|
177
211
|
|
|
212
|
+
(qualified_expression
|
|
213
|
+
name: (identifier) @property)
|
|
214
|
+
|
|
178
215
|
; ---- Patterns ----
|
|
179
216
|
(constructor_pattern
|
|
180
217
|
name: (identifier) @constructor)
|
|
@@ -185,15 +222,15 @@
|
|
|
185
222
|
; ---- Operators ----
|
|
186
223
|
[
|
|
187
224
|
"+" "-" "*" "/" "%" "!" "=" "==" "!=" "<" "<=" ">" ">=" "&&" "||"
|
|
188
|
-
"+=" "-=" "*=" "/=" "%=" ".." "..=" "
|
|
225
|
+
"+=" "-=" "*=" "/=" "%=" ".." "..=" "=>" "->" "?" "??"
|
|
189
226
|
"<<" ">>" "&=" "|=" "^=" "<<=" ">>="
|
|
190
|
-
"&" "|" "^" "~" "
|
|
227
|
+
"&" "|" "^" "~" "is" "&+" "&-" "&*"
|
|
191
228
|
] @operator
|
|
192
229
|
|
|
193
230
|
; ---- Punctuation ----
|
|
194
231
|
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
|
|
195
232
|
|
|
196
|
-
["," ";" ":" "
|
|
233
|
+
["," ";" ":" "." "@"] @punctuation.delimiter
|
|
197
234
|
|
|
198
235
|
; ---- Labels ----
|
|
199
236
|
(label) @label
|
|
@@ -203,4 +240,12 @@
|
|
|
203
240
|
"{" @punctuation.special
|
|
204
241
|
"}" @punctuation.special)
|
|
205
242
|
|
|
243
|
+
; ---- Actor expression (inline actor literal) ----
|
|
244
|
+
(actor_expression
|
|
245
|
+
"actor" @keyword.type
|
|
246
|
+
"|" @punctuation.bracket
|
|
247
|
+
"|" @punctuation.bracket)
|
|
206
248
|
|
|
249
|
+
; ---- Structured concurrency and recovery ----
|
|
250
|
+
(fork_expression "fork" @keyword)
|
|
251
|
+
(handle_expression "handle" @keyword error: (identifier) @variable.definition)
|
package/queries/indents.scm
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
[
|
|
4
4
|
(block)
|
|
5
5
|
(struct_declaration)
|
|
6
|
+
(tuple_type_declaration)
|
|
6
7
|
(enum_declaration)
|
|
7
8
|
(trait_declaration)
|
|
8
9
|
(impl_declaration)
|
|
9
10
|
(actor_declaration)
|
|
10
11
|
(supervisor_declaration)
|
|
11
|
-
(
|
|
12
|
+
(machine_declaration)
|
|
12
13
|
(extern_block)
|
|
13
14
|
(match_expression)
|
|
14
15
|
(select_expression)
|
|
15
|
-
(join_expression)
|
|
16
16
|
(if_expression)
|
|
17
17
|
(for_statement)
|
|
18
18
|
(while_statement)
|
package/queries/locals.scm
CHANGED
|
@@ -2,23 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
; Scope boundaries
|
|
4
4
|
(function_declaration) @local.scope
|
|
5
|
-
(async_function_declaration) @local.scope
|
|
6
5
|
(gen_function_declaration) @local.scope
|
|
7
|
-
(async_gen_function_declaration) @local.scope
|
|
8
6
|
(block) @local.scope
|
|
9
7
|
(for_statement) @local.scope
|
|
10
8
|
(while_statement) @local.scope
|
|
11
9
|
(loop_statement) @local.scope
|
|
12
10
|
(lambda) @local.scope
|
|
11
|
+
(actor_expression) @local.scope
|
|
13
12
|
(receive_function) @local.scope
|
|
14
13
|
(receive_gen_function) @local.scope
|
|
15
14
|
(match_arm) @local.scope
|
|
16
15
|
(if_expression) @local.scope
|
|
17
16
|
(scope_expression) @local.scope
|
|
17
|
+
(handle_expression) @local.scope
|
|
18
18
|
|
|
19
19
|
; Definitions
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
; Binding patterns keep the same identity in declarations, match arms,
|
|
21
|
+
; loops, select arms and condition chains, including nested payloads.
|
|
22
|
+
(pattern (identifier) @local.definition)
|
|
22
23
|
|
|
23
24
|
(var_statement
|
|
24
25
|
name: (identifier) @local.definition)
|
|
@@ -29,15 +30,9 @@
|
|
|
29
30
|
(lambda_parameter
|
|
30
31
|
name: (identifier) @local.definition)
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(scope_expression
|
|
36
|
-
binding: (identifier) @local.definition)
|
|
37
|
-
|
|
38
|
-
; Select arm bindings
|
|
39
|
-
(select_arm
|
|
40
|
-
(identifier) @local.definition)
|
|
33
|
+
; Task names use ordinary let bindings; recovery introduces its own binding.
|
|
34
|
+
(handle_expression
|
|
35
|
+
error: (identifier) @local.definition)
|
|
41
36
|
|
|
42
37
|
; References
|
|
43
38
|
(identifier) @local.reference
|