mirror of
https://codeberg.org/ProgramSnail/tree-sitter-lang.git
synced 2025-12-06 06:38:51 +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;
|
||||
}
|
||||
|
||||
( - ) 'a 'b = 'a + neg 'b;
|
||||
|
||||
test.something = {
|
||||
do_something a b c;
|
||||
}
|
||||
|
|
@ -588,6 +590,17 @@ arg_deduction_example 'name 'duration : <- String <- Float -> Task = Task 'name
|
|||
(tuple_access
|
||||
(simple_name_identifier)
|
||||
(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
|
||||
(simple_name_identifier)
|
||||
(block
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ type_definition: (DEFINITION_INFO)? (ANNOTATION_INFO)* ('^')?
|
|||
;
|
||||
|
||||
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)? ('->' | 'in') | ('<-' | 'out') | ('<>' | 'ref'))? type)+)?
|
||||
(('=' ( /*prec 2*/ block | (super_expression ';'))) | ';')
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ module.exports = grammar({
|
|||
repeat($.annotation_info),
|
||||
repeat(seq($.constraint, ';')),
|
||||
/*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(
|
||||
optional($.annotation_identifier),
|
||||
$.argument_name_identifier,
|
||||
|
|
@ -248,9 +248,7 @@ module.exports = grammar({
|
|||
_type_identifier: $ => choice($.argument_type_identifier, $.simple_type_identifier),
|
||||
|
||||
placeholder: $ => '_',
|
||||
|
||||
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]*/,
|
||||
typeclass_identifier: $ => /([a-z_][a-z0-9_]*\.)*#[A-Z][a-zA-Z0-9]*/,
|
||||
argument_name_identifier: $ => /'[a-z_][a-z0-9_]*/,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue