Add if expressions

This commit is contained in:
Bruno BELANYI 2022-06-01 20:18:10 +02:00
parent 93cd163707
commit 19c1f11414
5 changed files with 1661 additions and 913 deletions

View file

@ -47,6 +47,8 @@ module.exports = grammar({
$.sequence_expression,
$.assignment_expression,
$.if_expression,
),
nil_literal: (_) => "nil",
@ -167,6 +169,21 @@ module.exports = grammar({
field("right", $._expr),
),
),
if_expression: ($) => prec.right(
seq(
"if",
field("condition", $._expr),
"then",
field("consequence", $._expr),
optional(
seq(
"else",
field("alternative", $._expr),
),
),
),
),
}
});