Skip to content

Commit

Permalink
Support assignment to an implicit object chain
Browse files Browse the repository at this point in the history
  • Loading branch information
keidax committed Dec 19, 2024
1 parent fca0617 commit bd89120
Show file tree
Hide file tree
Showing 5 changed files with 405,822 additions and 399,896 deletions.
14 changes: 14 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2026,6 +2026,19 @@ module.exports = grammar({
)
},

// Assignment to a property of an implicit object
// `&.foo = a = b`
implicit_object_assign: $ => {
const chained_lhs = field('lhs',
alias($.implicit_call_chainable, $.implicit_object_call),
)
const rhs = field('rhs', $._expression)

return prec('assignment_operator',
seq(chained_lhs, '=', rhs),
)
},

implicit_object_tuple: $ => seq(
alias($._start_of_hash_or_tuple, '{'),
optional(seq(
Expand Down Expand Up @@ -2462,6 +2475,7 @@ module.exports = grammar({
choice(
$._expression,
$._implicit_object_call,
$.implicit_object_assign,
),
))
},
Expand Down
38 changes: 38 additions & 0 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bd89120

Please sign in to comment.