mirror of
https://codeberg.org/ProgramSnail/tree-sitter-lang.git
synced 2025-12-06 06:38:51 +00:00
typle access expression added
This commit is contained in:
parent
befa2f0395
commit
209ef22e0f
3 changed files with 27 additions and 1 deletions
|
|
@ -98,6 +98,10 @@ func_2 = {
|
||||||
=: Fruit @banana () -> "banana";
|
=: Fruit @banana () -> "banana";
|
||||||
|
|
||||||
%z := ( + ) 1 2;
|
%z := ( + ) 1 2;
|
||||||
|
|
||||||
|
// tuple access
|
||||||
|
%t := 1 & 2 & 3;
|
||||||
|
print t.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
test.something = {
|
test.something = {
|
||||||
|
|
@ -559,7 +563,23 @@ arg_deduction_example 'name 'duration : <- String <- Float -> Task = Task 'name
|
||||||
(name_expression
|
(name_expression
|
||||||
(operator)
|
(operator)
|
||||||
(number_literal)
|
(number_literal)
|
||||||
(number_literal))))))
|
(number_literal))))
|
||||||
|
(match
|
||||||
|
(name_definition
|
||||||
|
(simple_name_identifier))
|
||||||
|
(case
|
||||||
|
(operator_expression
|
||||||
|
(operator_expression
|
||||||
|
(number_literal)
|
||||||
|
(operator)
|
||||||
|
(number_literal))
|
||||||
|
(operator)
|
||||||
|
(number_literal))))
|
||||||
|
(name_expression
|
||||||
|
(simple_name_identifier)
|
||||||
|
(tuple_access
|
||||||
|
(simple_name_identifier)
|
||||||
|
(number_literal)))))
|
||||||
(function_definition
|
(function_definition
|
||||||
(simple_name_identifier)
|
(simple_name_identifier)
|
||||||
(block
|
(block
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,8 @@ name_definition: (('%' | 'let') | ('$' | 'var')) (SIMPLE_NAME_IDENTIFIER | PLACE
|
||||||
|
|
||||||
access: scoped_expression '[' super_expression ']' ;
|
access: scoped_expression '[' super_expression ']' ;
|
||||||
|
|
||||||
|
tuple_access: scoped_expression, '.' NUMBER_LITERAL
|
||||||
|
|
||||||
reference: /* prec -1 ?? */ (('<>' | 'ref') | ('<-' | 'in')) scoped_expression ;
|
reference: /* prec -1 ?? */ (('<>' | 'ref') | ('<-' | 'in')) scoped_expression ;
|
||||||
|
|
||||||
suffix_expression: scoped_expression ('?' | '!')
|
suffix_expression: scoped_expression ('?' | '!')
|
||||||
|
|
@ -111,6 +113,7 @@ scoped_expression: name_identifier
|
||||||
not_name_scoped_expression: PLACEHOLDER
|
not_name_scoped_expression: PLACEHOLDER
|
||||||
| name_definition
|
| name_definition
|
||||||
| access
|
| access
|
||||||
|
| tuple_access
|
||||||
| loop_control
|
| loop_control
|
||||||
| array
|
| array
|
||||||
| literal
|
| literal
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,8 @@ module.exports = grammar({
|
||||||
|
|
||||||
access: $ => seq($._scoped_expression, '[', $._super_expression, ']'),
|
access: $ => seq($._scoped_expression, '[', $._super_expression, ']'),
|
||||||
|
|
||||||
|
tuple_access: $ => seq($._scoped_expression, '.', $.number_literal),
|
||||||
|
|
||||||
loop_control: $ => choice('break', 'continue'),
|
loop_control: $ => choice('break', 'continue'),
|
||||||
|
|
||||||
reference: $ => prec(-1, seq(choice(choice('<>', 'ref'), choice('<-', 'in')), $._scoped_expression)),
|
reference: $ => prec(-1, seq(choice(choice('<>', 'ref'), choice('<-', 'in')), $._scoped_expression)),
|
||||||
|
|
@ -204,6 +206,7 @@ module.exports = grammar({
|
||||||
$.placeholder,
|
$.placeholder,
|
||||||
$.name_definition,
|
$.name_definition,
|
||||||
$.access,
|
$.access,
|
||||||
|
$.tuple_access,
|
||||||
$.loop_control,
|
$.loop_control,
|
||||||
$.reference,
|
$.reference,
|
||||||
$.suffix_expression,
|
$.suffix_expression,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue