Add type declarations

For now, simplified to type aliases only.
This commit is contained in:
Bruno BELANYI 2022-06-01 20:52:20 +02:00
parent e898312c95
commit 506fab8896
5 changed files with 2004 additions and 1701 deletions

View file

@ -228,12 +228,26 @@ module.exports = grammar({
_declaration_chunk: ($) => prec.left(
choice(
repeat1($.type_declaration),
repeat1(choice($.function_declaration, $.primitive_declaration)),
$.variable_declaration,
$.import_declaration,
),
),
type_declaration: ($) => seq(
"type",
field("name", $.identifier),
"=",
field("value", $._type)
),
_type: ($) => choice(
$.type_alias,
),
type_alias: ($) => $.identifier,
function_declaration: ($) => seq(
"function",
$._function_declaration_common,