Add modules

This commit is contained in:
Bruno BELANYI 2024-04-08 01:36:27 +01:00
parent a78ad8139f
commit 8bd249fc90
5 changed files with 2209 additions and 1317 deletions

View file

@ -19,6 +19,7 @@ module.exports = grammar({
_definition: ($) => choice(
$.assignment,
$.module,
),
comment: (_) => seq("#", /.*/),
@ -31,6 +32,26 @@ module.exports = grammar({
field("right", $._expr),
),
module: ($) => choice(
$._old_module,
$._new_module,
),
// This syntax is deprecated, but still accepted
_old_module: ($) => seq(
field("type", $.identifier),
"{",
optional(commaSeparated($._colon_property)),
"}",
),
_new_module: ($) => seq(
$.identifier,
"(",
optional(commaSeparated($._equal_property)),
")",
),
// }}}
// Expressions {{{
@ -168,6 +189,12 @@ module.exports = grammar({
field("value", $._expr),
),
_equal_property: ($) => seq(
field("field", $.identifier),
"=",
field("value", $._expr),
),
// }}}
}
});