block and array without = in function definition, Array and Function type shortcuts removed

This commit is contained in:
ProgramSnail 2024-02-23 15:07:55 +03:00
parent 154fbfb4d4
commit cbd923d0f1
4 changed files with 109 additions and 46 deletions

View file

@ -55,7 +55,7 @@ module.exports = grammar({
':',
repeat1($._annotated_type),
)),
choice(seq('=', choice(prec(2, choice($.block, $.array)), seq($._super_expression, ';'))), ';'),
choice(choice(prec(2, choice($.block, $.array)), seq('=', $._super_expression, ';')), ';'),
),
// datatype or typeclass definition
@ -222,13 +222,12 @@ module.exports = grammar({
repeat1(seq('&', $._annotated_type)),
),
function_type: $ => seq('((', repeat1($._annotated_type), '))'),
// for function type Function[...] or F[...] is used
// add annotations to in all types ??
_annotated_type: $ => seq(optional($.annotation_identifier), $._scoped_type),
// same to Array[...]
array_type: $ => seq('[[', $._type, ']]'),
// for array type Array[...] or A[...] is used
reference_type: $ => prec(-1, seq($._reference, $._scoped_type)),
@ -244,23 +243,18 @@ module.exports = grammar({
$.simple_type,
$.reference_type,
$.modified_type,
$.array_type,
$.variant_type,
$.tuple_type,
$.function_type,
),
_scoped_type: $ => choice(
$.simple_type,
$.reference_type,
$.modified_type,
$.array_type,
seq('(', choice(
$.variant_type,
$.tuple_type,
//$.function_type,
), ')'),
$.function_type,
),
// --- comments