mirror of
https://codeberg.org/ProgramSnail/tree-sitter-lang.git
synced 2026-01-25 13:07:09 +00:00
operator definitions
This commit is contained in:
parent
3b4be40ef7
commit
2e0dfdf3fa
3 changed files with 15 additions and 4 deletions
|
|
@ -106,6 +106,8 @@ func_2 = {
|
||||||
print t.0;
|
print t.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
( - ) 'a 'b = 'a + neg 'b;
|
||||||
|
|
||||||
test.something = {
|
test.something = {
|
||||||
do_something a b c;
|
do_something a b c;
|
||||||
}
|
}
|
||||||
|
|
@ -588,6 +590,17 @@ arg_deduction_example 'name 'duration : <- String <- Float -> Task = Task 'name
|
||||||
(tuple_access
|
(tuple_access
|
||||||
(simple_name_identifier)
|
(simple_name_identifier)
|
||||||
(number_literal)))))
|
(number_literal)))))
|
||||||
|
(function_definition
|
||||||
|
(operator)
|
||||||
|
(argument_name_identifier)
|
||||||
|
(argument_name_identifier)
|
||||||
|
(operator_expression
|
||||||
|
(name_expression
|
||||||
|
(argument_name_identifier))
|
||||||
|
(operator)
|
||||||
|
(name_expression
|
||||||
|
(simple_name_identifier)
|
||||||
|
(argument_name_identifier))))
|
||||||
(function_definition
|
(function_definition
|
||||||
(simple_name_identifier)
|
(simple_name_identifier)
|
||||||
(block
|
(block
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ type_definition: (DEFINITION_INFO)? (ANNOTATION_INFO)* ('^')?
|
||||||
;
|
;
|
||||||
|
|
||||||
function_definition: (definietion_info)? (ANNOTATION_INFO)* (constraint ';')*
|
function_definition: (definietion_info)? (ANNOTATION_INFO)* (constraint ';')*
|
||||||
(('%' | 'let') | ('$' | 'var'))? SIMPLE_NAME_IDENTIFIER
|
(('%' | 'let') | ('$' | 'var'))? (SIMPLE_NAME_IDENTIFIER | ('(' OPERATOR ')'))
|
||||||
((ANNOTATION_IDENTIFIER)? ARGUMENT_NAME_IDENTIFIER ('?')?)*
|
((ANNOTATION_IDENTIFIER)? ARGUMENT_NAME_IDENTIFIER ('?')?)*
|
||||||
(':' ((ANNOTATION_IDENTIFIER)? ('->' | 'in') | ('<-' | 'out') | ('<>' | 'ref'))? type)+)?
|
(':' ((ANNOTATION_IDENTIFIER)? ('->' | 'in') | ('<-' | 'out') | ('<>' | 'ref'))? type)+)?
|
||||||
(('=' ( /*prec 2*/ block | (super_expression ';'))) | ';')
|
(('=' ( /*prec 2*/ block | (super_expression ';'))) | ';')
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ module.exports = grammar({
|
||||||
repeat($.annotation_info),
|
repeat($.annotation_info),
|
||||||
repeat(seq($.constraint, ';')),
|
repeat(seq($.constraint, ';')),
|
||||||
/*optional(seq(*/optional(choice(choice('%', 'let'), choice('$', 'var')))/*, '.'))*/,
|
/*optional(seq(*/optional(choice(choice('%', 'let'), choice('$', 'var')))/*, '.'))*/,
|
||||||
field('name', $.simple_name_identifier),
|
choice(field('name', $.simple_name_identifier), seq('(', field('name', $.operator), ')')),
|
||||||
repeat(seq(
|
repeat(seq(
|
||||||
optional($.annotation_identifier),
|
optional($.annotation_identifier),
|
||||||
$.argument_name_identifier,
|
$.argument_name_identifier,
|
||||||
|
|
@ -248,9 +248,7 @@ module.exports = grammar({
|
||||||
_type_identifier: $ => choice($.argument_type_identifier, $.simple_type_identifier),
|
_type_identifier: $ => choice($.argument_type_identifier, $.simple_type_identifier),
|
||||||
|
|
||||||
placeholder: $ => '_',
|
placeholder: $ => '_',
|
||||||
|
|
||||||
simple_name_identifier: $ => token(seq(repeat(seq(/[a-z_][a-z0-9_]*/, '.')), /[a-z_][a-z0-9_]*/)),
|
simple_name_identifier: $ => token(seq(repeat(seq(/[a-z_][a-z0-9_]*/, '.')), /[a-z_][a-z0-9_]*/)),
|
||||||
|
|
||||||
simple_type_identifier: $ => /([a-z_][a-z0-9_]*\.)*[A-Z][a-zA-Z0-9]*/,
|
simple_type_identifier: $ => /([a-z_][a-z0-9_]*\.)*[A-Z][a-zA-Z0-9]*/,
|
||||||
typeclass_identifier: $ => /([a-z_][a-z0-9_]*\.)*#[A-Z][a-zA-Z0-9]*/,
|
typeclass_identifier: $ => /([a-z_][a-z0-9_]*\.)*#[A-Z][a-zA-Z0-9]*/,
|
||||||
argument_name_identifier: $ => /'[a-z_][a-z0-9_]*/,
|
argument_name_identifier: $ => /'[a-z_][a-z0-9_]*/,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue