tree-sitter grammar update

This commit is contained in:
2026-07-19 01:46:35 +02:00
parent 95f90cc306
commit 2e09864adf
6 changed files with 246106 additions and 213982 deletions
+15 -6
View File
@@ -25,6 +25,7 @@ module.exports = grammar({
conflicts: $ => [
[$.expression, $.qualified_identifier],
[$.constant_declaration, $.variable_declaration, $.expression],
[$.constant_declaration, $.variable_declaration, $.expression, $.qualified_identifier],
[$.function_declaration],
[$.if_statement],
[$.enum_literal],
@@ -36,7 +37,6 @@ module.exports = grammar({
[$.field_initializer, $.expression],
[$.tuple_literal],
[$.capture_list, $.expression],
[$.for_statement, $.expression],
[$.match_capture, $.expression],
],
@@ -149,7 +149,11 @@ module.exports = grammar({
),
record_field: $ => choice(
seq(field('name', $.identifier), field('type', choice($.type, $.struct_type))),
seq(
field('name', $.identifier),
field('type', choice($.type, $.struct_type)),
optional(seq('=', repeat($._newline), field('default', $.expression))),
),
field('type', choice($.type, $.struct_type)),
),
@@ -173,7 +177,7 @@ module.exports = grammar({
parameter: $ => seq(
optional('$'),
field('name', choice($.identifier, $.sink)),
repeat(seq(',', repeat($._newline), field('name', choice($.identifier, $.sink)))),
repeat(seq(',', repeat($._newline), optional('$'), field('name', choice($.identifier, $.sink)))),
field('type', $.type),
),
@@ -189,8 +193,11 @@ module.exports = grammar({
$.pointer_type,
$.array_type,
$.function_type,
$.parenthesized_type,
),
parenthesized_type: $ => seq('(', repeat($._newline), $.type, repeat($._newline), ')'),
named_type: $ => prec.right(seq(
$.qualified_identifier,
optional($.argument_list),
@@ -233,7 +240,7 @@ module.exports = grammar({
_type_constant: $ => seq(optional('-'), choice($.integer, $.character)),
builtin_type: _ => choice(
'void', 'anyopaque', 'bool', 'int', 'uint', 'float', 'range',
'void', 'type', 'anyopaque', 'bool', 'int', 'uint', 'float', 'range',
'i8', 'i16', 'i32', 'i64', 'u8', 'u16', 'u32', 'u64',
'isize', 'usize', 'f32', 'f64',
'c_char', 'c_schar', 'c_uchar', 'c_short', 'c_ushort',
@@ -365,16 +372,18 @@ module.exports = grammar({
repeat($._newline),
field('iterable', $.expression),
repeat($._newline),
'|',
$._for_capture_bar,
optional('@'),
field('item', $.identifier),
optional(seq(',', field('index', $.identifier))),
'|',
$._for_capture_bar,
repeat($._newline),
optional(seq(field('label', $.identifier), ':', repeat($._newline))),
field('body', $.block),
),
_for_capture_bar: _ => token(prec(1, '|')),
match_statement: $ => seq(
'match',
repeat($._newline),