mirror of
https://codeberg.org/ProgramSnail/tree-sitter-lang.git
synced 2025-12-24 23:48:44 +00:00
-> replaced with =>, added -> (in) in reference_expression, reference -> reference_expression
This commit is contained in:
parent
8cc264fa5a
commit
567f75620d
4 changed files with 77 additions and 72 deletions
30
grammar.js
30
grammar.js
|
|
@ -52,17 +52,17 @@ module.exports = grammar({
|
|||
optional($.definition_info),
|
||||
repeat($.annotation_info),
|
||||
repeat(seq($.constraint, ';')),
|
||||
/*optional(seq(*/optional(choice(choice('%', 'let'), choice('$', 'var')))/*, '.'))*/,
|
||||
/*optional(seq(*/optional($._var_let)/*, '.'))*/,
|
||||
choice(field('name', $.simple_name_identifier), seq('(', field('name', $.operator), ')')),
|
||||
repeat(seq(
|
||||
optional($.annotation_identifier),
|
||||
optional(choice(choice('->', 'out'), choice('<-', 'in'), choice('<>', 'ref'))),
|
||||
optional($._reference),
|
||||
$.argument_name_identifier,
|
||||
optional('?'),
|
||||
)),
|
||||
optional(seq(':', repeat1(seq(
|
||||
optional($.annotation_identifier),
|
||||
optional(choice(choice('->', 'out'), choice('<-', 'in'), choice('<>', 'ref'))),
|
||||
optional($._reference),
|
||||
$.type,
|
||||
)))),
|
||||
choice(seq('=', choice(prec(2, $.block), seq($._super_expression, ';'))), ';'),
|
||||
|
|
@ -82,7 +82,7 @@ module.exports = grammar({
|
|||
choice(':=', '=:'),
|
||||
$._expression,
|
||||
optional(seq(choice('??', 'if'), $._expression)),
|
||||
optional(seq(choice('->', 'do'), $._expression)),
|
||||
optional(seq($._do, $._expression)),
|
||||
),
|
||||
|
||||
match: $ => seq(
|
||||
|
|
@ -93,15 +93,15 @@ module.exports = grammar({
|
|||
condition: $ => seq(
|
||||
choice('??', 'if'),
|
||||
$._expression,
|
||||
choice('->', 'do'),
|
||||
$._do,
|
||||
$._expression,
|
||||
repeat(seq(
|
||||
choice('!!', 'elif'),
|
||||
$._expression,
|
||||
choice('->', 'do'),
|
||||
$._do,
|
||||
$._expression,
|
||||
)),
|
||||
optional(seq(choice('!!->', 'else'), $._expression)),
|
||||
optional(seq(choice('!!=>', 'else'), $._expression)),
|
||||
),
|
||||
|
||||
loop: $ => seq(
|
||||
|
|
@ -110,7 +110,7 @@ module.exports = grammar({
|
|||
field('condition', $._expression),
|
||||
seq(field('variable', $._expression), ':', field('interval', $._expression)),
|
||||
)),
|
||||
choice('->', 'do'),
|
||||
$._do,
|
||||
field('expression', $._expression),
|
||||
),
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ module.exports = grammar({
|
|||
return: $ => seq(choice('return', 'bring'), field('value', $._expression)),
|
||||
|
||||
name_definition: $ => seq(
|
||||
choice(choice('%', 'let'), choice('$', 'var')),
|
||||
$._var_let,
|
||||
choice($.simple_name_identifier, $.placeholder),
|
||||
),
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ module.exports = grammar({
|
|||
|
||||
loop_control: $ => choice('break', 'continue'),
|
||||
|
||||
reference: $ => prec(-1, seq(choice(choice('<>', 'ref'), choice('<-', 'in')), $._scoped_expression)),
|
||||
reference_expression: $ => prec(-1, seq($._reference, $._scoped_expression)),
|
||||
|
||||
suffix_expression: $ => seq($._scoped_expression, choice('?', '!')),
|
||||
|
||||
|
|
@ -168,9 +168,9 @@ module.exports = grammar({
|
|||
),
|
||||
|
||||
lambda: $ => seq(
|
||||
'\\',
|
||||
choice('\\', 'lambda'),
|
||||
repeat($.argument_name_identifier),
|
||||
'->',
|
||||
$._do,
|
||||
$._expression,
|
||||
),
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ module.exports = grammar({
|
|||
$.array_access,
|
||||
$.tuple_access,
|
||||
$.loop_control,
|
||||
$.reference,
|
||||
$.reference_expression,
|
||||
$.suffix_expression,
|
||||
$._literal,
|
||||
seq('(', $._super_expression, ')'),
|
||||
|
|
@ -245,6 +245,10 @@ module.exports = grammar({
|
|||
|
||||
// --- tokens
|
||||
|
||||
_do: $ => choice('=>', 'do'),
|
||||
_var_let: $ => choice(choice('%', 'let'), choice('$', 'var')),
|
||||
_reference: $ => choice(choice('->', 'out'), choice('<-', 'in'), choice('<>', 'ref')),
|
||||
|
||||
_name_identifier: $ => choice($.argument_name_identifier, $.simple_name_identifier),
|
||||
_type_identifier: $ => choice($.argument_type_identifier, $.simple_type_identifier),
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue