Add let expressions

This commit is contained in:
Bruno BELANYI 2022-06-01 20:36:14 +02:00
parent 68aac9a0ae
commit 1449aa939f
5 changed files with 2843 additions and 1754 deletions

View file

@ -54,6 +54,7 @@ module.exports = grammar({
$.while_expression,
$.for_expression,
$.break_expression,
$.let_expression,
),
nil_literal: (_) => "nil",
@ -210,6 +211,29 @@ module.exports = grammar({
break_expression: (_) => "break",
let_expression: ($) => seq(
"let",
field("declarations", optional($._declaration_chunks)),
"in",
field("body", sepBy(";", $._expr)),
"end",
),
// }}}
// Declarations {{{
_declaration_chunks: ($) => repeat1($._declaration_chunk),
_declaration_chunk: ($) => choice(
$.import_declaration,
),
import_declaration: ($) => seq(
"import",
field("file", $.string_literal),
),
// }}}
}
});