or references added

This commit is contained in:
ProgramSnail 2023-07-31 12:33:08 +03:00
parent 4159d81c4b
commit b71b732797
2 changed files with 23 additions and 12 deletions

View file

@ -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),