Add record types

This commit is contained in:
Bruno BELANYI 2022-06-01 20:53:39 +02:00
parent 506fab8896
commit dd0af53fa0
5 changed files with 970 additions and 736 deletions

View file

@ -244,10 +244,23 @@ module.exports = grammar({
_type: ($) => choice(
$.type_alias,
$.record_type,
),
type_alias: ($) => $.identifier,
record_type: ($) => seq(
"{",
sepBy(",", $._typed_field),
"}",
),
_typed_field: ($) => seq(
field("name", $.identifier),
":",
field("type", $.identifier),
),
function_declaration: ($) => seq(
"function",
$._function_declaration_common,
@ -271,12 +284,6 @@ module.exports = grammar({
")",
),
_typed_field: ($) => seq(
field("name", $.identifier),
":",
field("type", $.identifier),
),
variable_declaration: ($) => seq(
"var",
field("name", $.identifier),