Add lvalue expressions

This commit is contained in:
Bruno BELANYI 2022-06-01 20:07:00 +02:00
parent 8921953bbb
commit 6a3e4663ed
6 changed files with 1788 additions and 1150 deletions

View file

@ -20,6 +20,10 @@ module.exports = grammar({
// Ensure we don't extract keywords from tokens
word: ($) => $.identifier,
conflicts: ($) => [
[$._lvalue, $.array_expression],
],
rules: {
source_file: ($) => choice(
$._expr,
@ -33,6 +37,8 @@ module.exports = grammar({
$.array_expression,
$.record_expression,
$._lvalue,
$.function_call,
$.unary_expression,
@ -69,6 +75,25 @@ module.exports = grammar({
)
),
_lvalue: ($) => choice(
$.identifier,
$.record_value,
$.array_value,
),
record_value: ($) => seq(
field("record", $._lvalue),
".",
field("field", $.identifier),
),
array_value: ($) => seq(
field("array", $._lvalue),
"[",
field("index", $._expr),
"]",
),
function_call: ($) => seq(
field("function", $.identifier),
"(",