Skip to content

Commit

Permalink
fix: operator precedence rules for tagged template functions
Browse files Browse the repository at this point in the history
Co-authored-by: Amaan Qureshi <[email protected]>
  • Loading branch information
jackschu and amaanq authored Sep 2, 2024
1 parent d1e8d87 commit db26836
Show file tree
Hide file tree
Showing 5 changed files with 33,924 additions and 34,090 deletions.
9 changes: 7 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ module.exports = grammar({
precedences: $ => [
[
'member',
'template_call',
'call',
$.update_expression,
'unary_void',
Expand All @@ -78,7 +79,7 @@ module.exports = grammar({
$.arrow_function,
],
['assign', $.primary_expression],
['member', 'new', 'call', $.expression],
['member', 'template_call', 'new', 'call', $.expression],
['declaration', 'literal'],
[$.primary_expression, $.statement_block, 'object'],
[$.meta_property, $.import],
Expand Down Expand Up @@ -802,7 +803,11 @@ module.exports = grammar({
call_expression: $ => choice(
prec('call', seq(
field('function', choice($.expression, $.import)),
field('arguments', choice($.arguments, $.template_string)),
field('arguments', $.arguments),
)),
prec('template_call', seq(
field('function', choice($.primary_expression, $.new_expression)),
field('arguments', $.template_string),
)),
prec('member', seq(
field('function', $.primary_expression),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
},
"scripts": {
"install": "node-gyp-build",
"lint": "eslint grammar.js",
"prestart": "tree-sitter build --wasm",
"start": "tree-sitter playground",
"test": "node --test bindings/node/*_test.js"
Expand Down
37 changes: 35 additions & 2 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 db26836

Please sign in to comment.