mirror of
https://codeberg.org/ProgramSnail/tree-sitter-lang.git
synced 2025-12-06 06:38:51 +00:00
or references added
This commit is contained in:
parent
4159d81c4b
commit
b71b732797
2 changed files with 23 additions and 12 deletions
|
|
@ -220,7 +220,7 @@ parse_number : Unit! = {
|
|||
}
|
||||
|
||||
: example of or_in and or_out usage for template operators (tuple input and tuple output)
|
||||
( & ) |-> 'a |-> 'b <-| 'x <-| 'y = ('a := 'x) && ('b := 'y);
|
||||
( & ) --|-> 'a --|-> 'b <-|-- 'x <-|-- 'y = ('a := 'x) && ('b := 'y);
|
||||
|
||||
: function, that return result ('!' not used on calls)
|
||||
: useful when tuples returned
|
||||
|
|
|
|||
33
grammar.js
33
grammar.js
|
|
@ -18,8 +18,8 @@ module.exports = grammar({
|
|||
|
||||
_statement: $ => choice(
|
||||
$.import,
|
||||
$.type_definition,
|
||||
$.function_definition,
|
||||
$.type_definition,
|
||||
$.typeclass_definition,
|
||||
$.empty_lines,
|
||||
),
|
||||
|
|
@ -41,15 +41,6 @@ module.exports = grammar({
|
|||
|
||||
// --- definitions
|
||||
|
||||
type_definition: $ => seq(
|
||||
optional($.definition_info),
|
||||
repeat($.annotation_info),
|
||||
optional('^'),
|
||||
field('name', $.simple_type_identifier),
|
||||
optional(seq(repeat($.argument_type_identifier), '=', $.variant_type)),
|
||||
choice(seq('{', repeat($.function_definition), '}'), ';')
|
||||
),
|
||||
|
||||
function_definition: $ => seq(
|
||||
optional($.definition_info),
|
||||
repeat($.annotation_info),
|
||||
|
|
@ -71,6 +62,15 @@ module.exports = grammar({
|
|||
choice(seq('=', choice(prec(2, choice($.block, $.array)), seq($._super_expression, ';'))), ';'),
|
||||
),
|
||||
|
||||
type_definition: $ => seq(
|
||||
optional($.definition_info),
|
||||
repeat($.annotation_info),
|
||||
optional('^'),
|
||||
field('name', $.simple_type_identifier),
|
||||
optional(seq(repeat($.argument_type_identifier), '=', $.variant_type)),
|
||||
choice(seq('{', repeat($.function_definition), '}'), ';')
|
||||
),
|
||||
|
||||
typeclass_definition: $ => seq(
|
||||
optional($.definition_info),
|
||||
// no argumenmts => no annotation info
|
||||
|
|
@ -256,7 +256,18 @@ module.exports = grammar({
|
|||
_do: $ => choice('=>', 'do'),
|
||||
_var_let: $ => choice(choice('%', 'let'), choice('$', 'var')),
|
||||
_optional_result: $ => choice('?', '!'),
|
||||
_reference: $ => choice(choice('->', 'out'), choice('<-', 'in'), choice('<>', 'ref'), choice('|->', 'or_out'), choice('<-|', 'or_in')),
|
||||
//_reference: $ => choice(choice('->', 'out'), choice('<-', 'in'), choice('<>', 'ref'), choice('|->', 'or_out'), choice('<-|', 'or_in')),
|
||||
|
||||
// _reference: $ => seq(optional(choice('->', 'out')), optional(choice('<>', 'ref')), optional(choice('--', 'const')), optional(choice('<-', 'in'))),
|
||||
|
||||
_reference: $ => choice(choice('<-', '<>', '--', '->',
|
||||
'<-|<>', '<-|--', '<>|->', '--|->', '<>|--', '<-|->',
|
||||
'<-|<>|->', '<-|--|->', '<-|<>|--', '<>|--|->',
|
||||
'<-|<>|--|->'),
|
||||
choice('in', 'ref', 'const', 'out',
|
||||
'in|ref', 'in|const', 'ref|out', 'const|out', 'ref|const', 'in|out',
|
||||
'in|ref|out', 'in|const|out', 'in|ref|const', 'ref|const|out',
|
||||
'in|ref|const|out')),
|
||||
|
||||
_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