Add assignment expressions

This commit is contained in:
Bruno BELANYI 2022-06-01 20:11:52 +02:00
parent 6a3e4663ed
commit 93cd163707
5 changed files with 1316 additions and 1023 deletions

View file

@ -7,6 +7,7 @@ function sepBy(sep, rule) {
}
const PREC = {
assign: 6,
multiplicative: 5,
additive: 4,
comparative: 3,
@ -44,6 +45,8 @@ module.exports = grammar({
$.unary_expression,
$.binary_expression,
$.sequence_expression,
$.assignment_expression,
),
nil_literal: (_) => "nil",
@ -155,6 +158,15 @@ module.exports = grammar({
),
"}",
),
assignment_expression: ($) => prec.right(
PREC.assign,
seq(
field("left", $._lvalue),
":=",
field("right", $._expr),
),
),
}
});