@hew-lang/tree-sitter-hew 1.0.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 ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@hew-lang/tree-sitter-hew",
3
+ "version": "1.0.0",
4
+ "description": "Hew grammar for tree-sitter",
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/hew-lang/tree-sitter-hew.git"
9
+ },
10
+ "funding": "",
11
+ "license": "Apache-2.0",
12
+ "author": {
13
+ "name": "Hew Contributors",
14
+ "url": "https://hew.sh"
15
+ },
16
+ "main": "bindings/node",
17
+ "types": "bindings/node",
18
+ "keywords": [
19
+ "incremental",
20
+ "parsing",
21
+ "tree-sitter",
22
+ "hew"
23
+ ],
24
+ "files": [
25
+ "grammar.js",
26
+ "tree-sitter.json",
27
+ "binding.gyp",
28
+ "prebuilds/**",
29
+ "bindings/node/index.js",
30
+ "bindings/node/index.d.ts",
31
+ "bindings/node/binding.cc",
32
+ "queries/*",
33
+ "src/**",
34
+ "*.wasm"
35
+ ],
36
+ "dependencies": {
37
+ "node-addon-api": "^8.5.0",
38
+ "node-gyp-build": "^4.8.4"
39
+ },
40
+ "devDependencies": {
41
+ "prebuildify": "^6.0.1",
42
+ "tree-sitter": "^0.25.0",
43
+ "tree-sitter-cli": "^0.26.5"
44
+ },
45
+ "peerDependencies": {
46
+ "tree-sitter": "^0.25.0"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "tree-sitter": {
50
+ "optional": true
51
+ }
52
+ },
53
+ "scripts": {
54
+ "install": "node-gyp-build",
55
+ "prestart": "tree-sitter build --wasm",
56
+ "start": "tree-sitter playground",
57
+ "test": "node --test bindings/node/*_test.js"
58
+ }
59
+ }
@@ -0,0 +1,23 @@
1
+ ; folds.scm — Foldable regions for Hew
2
+
3
+ [
4
+ (block)
5
+ (function_declaration)
6
+ (async_function_declaration)
7
+ (gen_function_declaration)
8
+ (async_gen_function_declaration)
9
+ (struct_declaration)
10
+ (enum_declaration)
11
+ (trait_declaration)
12
+ (impl_declaration)
13
+ (actor_declaration)
14
+ (supervisor_declaration)
15
+ (wire_declaration)
16
+ (extern_block)
17
+ (receive_function)
18
+ (receive_gen_function)
19
+ (if_expression)
20
+ (match_expression)
21
+ (select_expression)
22
+ (join_expression)
23
+ ] @fold
@@ -0,0 +1,186 @@
1
+ ; highlights.scm — Hew syntax highlighting queries for tree-sitter
2
+
3
+ ; ---- Keywords ----
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"
8
+ "type" "where" "dyn" "unsafe" "defer"
9
+ "init" "child" "restart" "budget" "strategy"
10
+ "package" "super" "after" "from"
11
+ "reserved" "optional" "deprecated" "default"
12
+ ] @keyword
13
+
14
+ "receive" @keyword
15
+
16
+ (cooperate_expression) @keyword
17
+
18
+ [
19
+ "enum" "trait" "impl" "actor" "supervisor" "wire"
20
+ ] @keyword.type
21
+
22
+ "pure" @keyword
23
+
24
+ [
25
+ "permanent" "transient" "temporary"
26
+ "one_for_one" "one_for_all" "rest_for_one"
27
+ ] @constant.builtin
28
+
29
+ ; ---- Attributes ----
30
+ (attribute "#" @punctuation.special)
31
+ (attribute "[" @punctuation.special)
32
+ (attribute "]" @punctuation.special)
33
+ (attribute (identifier) @attribute)
34
+
35
+ ; ---- Literals ----
36
+ (integer_literal) @number
37
+ (float_literal) @number.float
38
+ (duration_literal) @number
39
+
40
+ (string_literal) @string
41
+ (raw_string_literal) @string
42
+ (regex_literal) @string.regexp
43
+ (interpolated_string) @string
44
+ (fstring_start) @string.special
45
+ (string_content) @string
46
+ (escape_sequence) @string.escape
47
+
48
+ (boolean_literal) @boolean
49
+ (none_literal) @constant.builtin
50
+
51
+ ; ---- Comments ----
52
+ (line_comment) @comment
53
+ (block_comment) @comment
54
+
55
+ ; ---- Types ----
56
+ (primitive_type) @type.builtin
57
+
58
+ (type_parameters "<" @punctuation.bracket)
59
+ (type_parameters ">" @punctuation.bracket)
60
+
61
+ ; ---- Functions ----
62
+ (function_declaration
63
+ name: (identifier) @function)
64
+
65
+ (async_function_declaration
66
+ name: (identifier) @function)
67
+
68
+ (gen_function_declaration
69
+ name: (identifier) @function)
70
+
71
+ (async_gen_function_declaration
72
+ name: (identifier) @function)
73
+
74
+ (trait_function_signature
75
+ name: (identifier) @function)
76
+
77
+ (receive_function
78
+ name: (identifier) @function.method)
79
+
80
+ (receive_gen_function
81
+ name: (identifier) @function.method)
82
+
83
+ ; Function calls: foo(x)
84
+ (call_expression
85
+ function: (expression (identifier) @function.call))
86
+
87
+ ; Method calls: obj.method(x) — parsed as call(field_expr)
88
+ (call_expression
89
+ function: (expression
90
+ (field_expression
91
+ field: (identifier) @function.method.call)))
92
+
93
+ ; Named arguments in calls
94
+ (call_argument
95
+ name: (identifier) @property)
96
+
97
+ ; ---- Variables & Parameters ----
98
+ (parameter
99
+ name: (identifier) @variable.parameter)
100
+
101
+ (lambda_parameter
102
+ name: (identifier) @variable.parameter)
103
+
104
+ (self) @variable.builtin
105
+
106
+ (field_expression
107
+ field: (identifier) @property)
108
+
109
+ (struct_field
110
+ name: (identifier) @property)
111
+
112
+ (actor_field
113
+ name: (identifier) @property)
114
+
115
+ ; ---- Declarations ----
116
+ (struct_declaration
117
+ name: (identifier) @type)
118
+
119
+ (enum_declaration
120
+ name: (identifier) @type)
121
+
122
+ (trait_declaration
123
+ name: (identifier) @type)
124
+
125
+ (impl_declaration
126
+ trait: (identifier) @type)
127
+
128
+ (impl_declaration
129
+ type: (identifier) @type)
130
+
131
+ (actor_declaration
132
+ name: (identifier) @type)
133
+
134
+ (supervisor_declaration
135
+ name: (identifier) @type)
136
+
137
+ (wire_declaration
138
+ name: (identifier) @type)
139
+
140
+ (type_alias
141
+ name: (identifier) @type)
142
+
143
+ (variant
144
+ name: (identifier) @constant)
145
+
146
+ ; ---- Struct init ----
147
+ (struct_init
148
+ name: (identifier) @type)
149
+
150
+ (field_initializer
151
+ name: (identifier) @property)
152
+
153
+ ; ---- Paths ----
154
+ (path_expression
155
+ (identifier) @type
156
+ (identifier) @property)
157
+
158
+ ; ---- Patterns ----
159
+ (constructor_pattern
160
+ name: (identifier) @constructor)
161
+
162
+ (constructor_pattern
163
+ name: (path_expression) @constructor)
164
+
165
+ ; ---- Operators ----
166
+ [
167
+ "+" "-" "*" "/" "%" "!" "=" "==" "!=" "<" "<=" ">" ">=" "&&" "||"
168
+ "+=" "-=" "*=" "/=" "%=" ".." "..=" "<-" "=>" "->" "?"
169
+ "<<" ">>" "&=" "|=" "^=" "<<=" ">>="
170
+ "&" "|" "^" "~" "=~" "!~"
171
+ ] @operator
172
+
173
+ ; ---- Punctuation ----
174
+ ["(" ")" "[" "]" "{" "}"] @punctuation.bracket
175
+
176
+ ["," ";" ":" "::" "." "@"] @punctuation.delimiter
177
+
178
+ ; ---- Labels ----
179
+ (label) @label
180
+
181
+ ; ---- Strings interpolation ----
182
+ (interpolation
183
+ "{" @punctuation.special
184
+ "}" @punctuation.special)
185
+
186
+
@@ -0,0 +1,27 @@
1
+ ; indents.scm — Indentation rules for Hew
2
+
3
+ [
4
+ (block)
5
+ (struct_declaration)
6
+ (enum_declaration)
7
+ (trait_declaration)
8
+ (impl_declaration)
9
+ (actor_declaration)
10
+ (supervisor_declaration)
11
+ (wire_declaration)
12
+ (extern_block)
13
+ (match_expression)
14
+ (select_expression)
15
+ (join_expression)
16
+ (if_expression)
17
+ (for_statement)
18
+ (while_statement)
19
+ (loop_statement)
20
+ (lambda)
21
+ ] @indent
22
+
23
+ [
24
+ "}"
25
+ "]"
26
+ ")"
27
+ ] @outdent
@@ -0,0 +1,43 @@
1
+ ; locals.scm — Variable scoping for Hew
2
+
3
+ ; Scope boundaries
4
+ (function_declaration) @local.scope
5
+ (async_function_declaration) @local.scope
6
+ (gen_function_declaration) @local.scope
7
+ (async_gen_function_declaration) @local.scope
8
+ (block) @local.scope
9
+ (for_statement) @local.scope
10
+ (while_statement) @local.scope
11
+ (loop_statement) @local.scope
12
+ (lambda) @local.scope
13
+ (receive_function) @local.scope
14
+ (receive_gen_function) @local.scope
15
+ (match_arm) @local.scope
16
+ (if_expression) @local.scope
17
+ (scope_expression) @local.scope
18
+
19
+ ; Definitions
20
+ (let_statement
21
+ pattern: (pattern (identifier) @local.definition))
22
+
23
+ (var_statement
24
+ name: (identifier) @local.definition)
25
+
26
+ (parameter
27
+ name: (identifier) @local.definition)
28
+
29
+ (lambda_parameter
30
+ name: (identifier) @local.definition)
31
+
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)
41
+
42
+ ; References
43
+ (identifier) @local.reference