@hew-lang/tree-sitter-hew 1.0.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hew-lang/tree-sitter-hew",
3
- "version": "1.0.1",
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": "^0.26.5"
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
- (wire_declaration)
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
@@ -2,28 +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" "join"
7
- "import" "extern" "async" "gen" "yield" "scope" "move"
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" "restart" "budget" "strategy"
10
- "package" "super" "after" "from"
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
- (cooperate_expression) @keyword
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" "wire"
41
+ "enum" "trait" "impl" "actor" "supervisor" "machine"
20
42
  ] @keyword.type
21
43
 
22
- "pure" @keyword
44
+ [
45
+ "state" "on" "when"
46
+ "events" "emits" "reenter" "entry" "exit" "emit" "initial"
47
+ "mailbox" "overflow" "strategy" "intensity" "within"
48
+ ] @keyword
49
+
50
+ [
51
+ "block" "drop_new" "drop_old" "fail" "coalesce" "fallback"
52
+ ] @constant.builtin
23
53
 
24
54
  [
25
55
  "permanent" "transient" "temporary"
26
- "one_for_one" "one_for_all" "rest_for_one"
27
56
  ] @constant.builtin
28
57
 
29
58
  ; ---- Attributes ----
@@ -39,6 +68,7 @@
39
68
 
40
69
  (string_literal) @string
41
70
  (raw_string_literal) @string
71
+ (byte_string_literal) @string
42
72
  (regex_literal) @string.regexp
43
73
  (interpolated_string) @string
44
74
  (fstring_start) @string.special
@@ -52,25 +82,28 @@
52
82
  (line_comment) @comment
53
83
  (block_comment) @comment
54
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
+
55
90
  ; ---- Types ----
56
91
  (primitive_type) @type.builtin
57
92
 
58
93
  (type_parameters "<" @punctuation.bracket)
59
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)
60
99
 
61
100
  ; ---- Functions ----
62
101
  (function_declaration
63
102
  name: (identifier) @function)
64
103
 
65
- (async_function_declaration
66
- name: (identifier) @function)
67
-
68
104
  (gen_function_declaration
69
105
  name: (identifier) @function)
70
106
 
71
- (async_gen_function_declaration
72
- name: (identifier) @function)
73
-
74
107
  (trait_function_signature
75
108
  name: (identifier) @function)
76
109
 
@@ -123,10 +156,10 @@
123
156
  name: (identifier) @type)
124
157
 
125
158
  (impl_declaration
126
- trait: (identifier) @type)
159
+ type: (identifier) @type)
127
160
 
128
161
  (impl_declaration
129
- type: (identifier) @type)
162
+ self_type: (identifier) @type)
130
163
 
131
164
  (actor_declaration
132
165
  name: (identifier) @type)
@@ -134,12 +167,33 @@
134
167
  (supervisor_declaration
135
168
  name: (identifier) @type)
136
169
 
137
- (wire_declaration
170
+ (machine_declaration
138
171
  name: (identifier) @type)
139
172
 
173
+ (machine_state
174
+ name: (identifier) @constant)
175
+
176
+ (machine_event_decl
177
+ name: (identifier) @constant)
178
+
179
+ (machine_transition
180
+ event: (identifier) @constant)
181
+
182
+ (emit_statement
183
+ event: (identifier) @constant)
184
+
185
+ (map_entry
186
+ key: (expression) @property)
187
+
140
188
  (type_alias
141
189
  name: (identifier) @type)
142
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
+
143
197
  (variant
144
198
  name: (identifier) @constant)
145
199
 
@@ -155,6 +209,9 @@
155
209
  (identifier) @type
156
210
  (identifier) @property)
157
211
 
212
+ (qualified_expression
213
+ name: (identifier) @property)
214
+
158
215
  ; ---- Patterns ----
159
216
  (constructor_pattern
160
217
  name: (identifier) @constructor)
@@ -165,15 +222,15 @@
165
222
  ; ---- Operators ----
166
223
  [
167
224
  "+" "-" "*" "/" "%" "!" "=" "==" "!=" "<" "<=" ">" ">=" "&&" "||"
168
- "+=" "-=" "*=" "/=" "%=" ".." "..=" "<-" "=>" "->" "?"
225
+ "+=" "-=" "*=" "/=" "%=" ".." "..=" "=>" "->" "?" "??"
169
226
  "<<" ">>" "&=" "|=" "^=" "<<=" ">>="
170
- "&" "|" "^" "~" "=~" "!~"
227
+ "&" "|" "^" "~" "is" "&+" "&-" "&*"
171
228
  ] @operator
172
229
 
173
230
  ; ---- Punctuation ----
174
231
  ["(" ")" "[" "]" "{" "}"] @punctuation.bracket
175
232
 
176
- ["," ";" ":" "::" "." "@"] @punctuation.delimiter
233
+ ["," ";" ":" "." "@"] @punctuation.delimiter
177
234
 
178
235
  ; ---- Labels ----
179
236
  (label) @label
@@ -183,4 +240,12 @@
183
240
  "{" @punctuation.special
184
241
  "}" @punctuation.special)
185
242
 
243
+ ; ---- Actor expression (inline actor literal) ----
244
+ (actor_expression
245
+ "actor" @keyword.type
246
+ "|" @punctuation.bracket
247
+ "|" @punctuation.bracket)
186
248
 
249
+ ; ---- Structured concurrency and recovery ----
250
+ (fork_expression "fork" @keyword)
251
+ (handle_expression "handle" @keyword error: (identifier) @variable.definition)
@@ -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
- (wire_declaration)
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)
@@ -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
- (let_statement
21
- pattern: (pattern (identifier) @local.definition))
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
- (for_statement
33
- pattern: (pattern (identifier) @local.definition))
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