Skip to content

Commit b0dfe3b

Browse files
committed
Refactor: Remove redundant forall_keyword from various definitions
- Eliminated unnecessary forall_keyword nodes from function and block definitions in function.txt, basic_concepts.txt, functions.txt, general-description.txt, and statements.txt to streamline the syntax tree. - Adjusted formatting in struct.txt for consistency in identifier declarations. - Updated author email in tree-sitter.json for Georgii Plotnikov.
1 parent 60b9be9 commit b0dfe3b

File tree

15 files changed

+6203
-6299
lines changed

15 files changed

+6203
-6299
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"]
2020
path = "bindings/rust/lib.rs"
2121

2222
[dependencies]
23-
tree-sitter = ">=0.24.6"
23+
tree-sitter = ">=0.25.6"
2424

2525
[build-dependencies]
26-
cc = "1.2.6"
26+
cc = "1.2.26"

grammar.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ module.exports = grammar({
185185
choice($.attribute_access_operator, $.expand_operator),
186186
field('name', $._simple_name),
187187
)),
188-
188+
189189
function_call_expression: $ => prec.dynamic(PRECEDENCE.FUNC_CALL, seq(
190190
field('function', $._lval_expression),
191191
optional(field('type_parameters', alias($.type_argument_list, $.type_parameters))),
@@ -207,14 +207,14 @@ module.exports = grammar({
207207
$._expression,
208208
$._terminal_symbol
209209
),
210-
210+
211211
assign_statement: $ => prec.left(seq(
212212
field('left', $._lval_expression),
213213
$.assign_operator,
214214
field('right', $._expression),
215215
$._terminal_symbol,
216216
)),
217-
217+
218218
assert_statement: $ => seq(
219219
'assert',
220220
$._expression,
@@ -374,28 +374,28 @@ module.exports = grammar({
374374
),
375375

376376
ignore_argument: $ => seq(
377-
'_',
377+
'_',
378378
$._typedef_symbol,
379379
field('type', $._type)
380380
),
381381

382382
assume_block: $ => seq(
383-
'assume',
383+
$._assume_keyword,
384384
field('body', $.block),
385385
),
386386

387387
forall_block: $ => seq(
388-
$.forall_keyword,
388+
$._forall_keyword,
389389
field('body', $.block),
390390
),
391391

392392
exists_block: $ => seq(
393-
'exists',
393+
$._exists_keyword,
394394
field('body', $.block),
395395
),
396-
396+
397397
unique_block: $ => seq(
398-
'unique',
398+
$._unique_keyword,
399399
field('body', $.block),
400400
),
401401

@@ -445,7 +445,10 @@ module.exports = grammar({
445445
),
446446

447447
function_keyword: _ => 'fn',
448-
forall_keyword: _ => 'forall',
448+
_forall_keyword: _ => 'forall',
449+
_assume_keyword: _ => 'assume',
450+
_exists_keyword: _ => 'exists',
451+
_unique_keyword: _ => 'unique',
449452
uzumaki_keyword: _ => '@',
450453
mut_keyword: _ => 'mut',
451454

@@ -483,9 +486,9 @@ module.exports = grammar({
483486
_rcb_symbol: _ => '}',
484487
_lrb_symbol: _ => '(',
485488
_rrb_symbol: _ => ')',
486-
_comma_symbol: $ => ',',
487-
_typedef_symbol: $ => ':',
488-
_terminal_symbol: $ => ';',
489+
_comma_symbol: _ => ',',
490+
_typedef_symbol: _ => ':',
491+
_terminal_symbol: _ => ';',
489492

490493

491494
bool_literal: _ => choice(
@@ -503,7 +506,7 @@ module.exports = grammar({
503506

504507
number_literal: $ => seq(optional('-'), /\d+/),
505508

506-
unit_literal: $ => '()',
509+
unit_literal: _ => '()',
507510

508511
array_literal: $ => seq(
509512
'[',
@@ -544,7 +547,6 @@ module.exports = grammar({
544547
type_argument_list_definition: $ => seq(
545548
'<',
546549
choice(
547-
repeat(','),
548550
sep1(field('type', $.identifier), $._comma_symbol),
549551
),
550552
'>',
@@ -553,7 +555,6 @@ module.exports = grammar({
553555
type_argument_list: $ => seq(
554556
'<',
555557
choice(
556-
repeat(','),
557558
sep1(field('type', $._type), $._comma_symbol),
558559
),
559560
'>',

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
}
5555
},
5656
"devDependencies": {
57-
"eslint": "9.27.0",
57+
"eslint": "9.28.0",
5858
"eslint-config-google": "^0.14.0",
5959
"prebuildify": "^6.0.1",
60-
"tree-sitter-cli": "0.25.4"
60+
"tree-sitter-cli": "0.25.5"
6161
},
6262
"files": [
6363
"grammar.js",

queries/highlights.scm

Lines changed: 61 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,77 @@
11
;; Comments
22
(comment) @comment
33

4-
;; Punctuation symbols
5-
[ ";" ":" "," "{" "}" "(" ")" "[" "]" "<" ">" ] @punctuation
6-
7-
[ "struct" "enum" "const" "spec" "return" "self" "loop" "let" "assume" "exists" "unique" "if" "else" "break" "use" "from" "assert" "type" "external" ] @keyword
8-
9-
;; Operators (node types from grammar.js)
10-
(assign_operator) @operator
11-
(rightarrow_operator) @operator
12-
(expand_operator) @operator
13-
(attribute_access_operator) @operator
14-
(add_operator) @operator
15-
(sub_operator) @operator
16-
(mul_operator) @operator
17-
(pow_operator) @operator
18-
(mod_operator) @operator
19-
(equals_operator) @operator
20-
(not_equals_operator) @operator
21-
(less_operator) @operator
22-
(greater_operator) @operator
23-
(less_equal_operator) @operator
24-
(greater_equal_operator) @operator
25-
(and_operator) @operator
26-
(or_operator) @operator
27-
(bit_and_operator) @operator
28-
(bit_or_operator) @operator
29-
(bit_xor_operator) @operator
30-
(shift_left_operator) @operator
31-
(shift_right_operator) @operator
32-
(unary_not) @operator
33-
34-
;; Keywords (token nodes)
35-
36-
((function_keyword) @keyword)
37-
((forall_keyword) @keyword)
38-
((mut_keyword) @keyword)
39-
40-
;; Boolean literals
41-
(bool_literal) @boolean
4+
;; Punctuation
5+
6+
[ ";" "," ] @punctuation.delimiter
7+
[ "(" ")" "{" "}" "[" "]" ] @punctuation.bracket
8+
"->" @punctuation.special
9+
10+
;; Keywords
11+
"const" @keyword.modifier
12+
13+
(forall_block
14+
("forall" @keyword.modifier))
15+
16+
(assume_block
17+
("assume" @keyword.modifier) )
18+
19+
(unique_block
20+
("unique" @keyword.modifier) )
4221

22+
(exists_block
23+
("exists" @keyword.modifier))
24+
25+
"spec" @keyword.type
26+
"struct" @keyword.type
27+
"enum" @keyword.type
28+
"return" @keyword.return
29+
(function_keyword) @keyword.function
30+
[ "use" "external" ] @keyword.import
31+
[ "if" "else" ] @keyword.conditional
32+
"let" @keyword
33+
"type" @keyword
4334
;; Types
44-
(type_i8) @type (type_i16) @type (type_i32) @type (type_i64) @type
45-
(type_u8) @type (type_u16) @type (type_u32) @type (type_u64) @type
46-
(type_bool) @type (type_unit) @type
35+
36+
(type_i8) @type.builtin
37+
(type_i16) @type.builtin
38+
(type_i32) @type.builtin
39+
(type_i64) @type.builtin
40+
(type_u8) @type.builtin
41+
(type_u16) @type.builtin
42+
(type_u32) @type.builtin
43+
(type_u64) @type.builtin
44+
(type_bool) @type.builtin
45+
(type_unit) @type.builtin
46+
(type_array) @type.builtin
47+
(type_fn) @type.builtin
4748

4849
;; Literals
49-
(string_literal) @string
5050
(number_literal) @number
51-
(unit_literal) @constant
52-
(uzumaki_keyword) @constant
53-
54-
;; Identifiers
55-
(identifier) @identifier
51+
(bool_literal) @boolean
52+
(unit_literal) @number.float
5653

57-
;; Name definitions
58-
(variable_definition_statement
59-
name: (identifier) @variable)
54+
;; Definitions
6055
(constant_definition
6156
name: (identifier) @constant)
57+
58+
(enum_definition
59+
name: (identifier) @type.definition
60+
variant: (identifier) @variable.member)
61+
6262
(function_definition
6363
name: (identifier) @function)
64-
(external_function_definition
65-
name: (identifier) @function)
66-
(type_definition_statement
67-
name: (identifier) @type.definition)
68-
(enum_definition
69-
name: (identifier) @type.definition)
64+
7065
(struct_definition
66+
name: (identifier) @type.definition
67+
(struct_field
68+
name: (identifier) @variable.member
69+
type: (identifier) @type))
70+
71+
(spec_definition
7172
name: (identifier) @type.definition)
72-
(member_access_expression
73-
expression: ( (identifier) @type.definition)
74-
)
73+
74+
;; Expressions
7575
(function_call_expression
76-
function: ( (identifier) @function)
77-
)
78-
(qualified_name
79-
qualifier: ( (identifier) @type.definition)
80-
name: (identifier) @type.definition)
76+
function: (identifier) @function.call)
77+

0 commit comments

Comments
 (0)