Skip to content

Commit db26836

Browse files
jackschuamaanq
andauthored
fix: operator precedence rules for tagged template functions
Co-authored-by: Amaan Qureshi <[email protected]>
1 parent d1e8d87 commit db26836

File tree

5 files changed

+33924
-34090
lines changed

5 files changed

+33924
-34090
lines changed

grammar.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ module.exports = grammar({
5858
precedences: $ => [
5959
[
6060
'member',
61+
'template_call',
6162
'call',
6263
$.update_expression,
6364
'unary_void',
@@ -78,7 +79,7 @@ module.exports = grammar({
7879
$.arrow_function,
7980
],
8081
['assign', $.primary_expression],
81-
['member', 'new', 'call', $.expression],
82+
['member', 'template_call', 'new', 'call', $.expression],
8283
['declaration', 'literal'],
8384
[$.primary_expression, $.statement_block, 'object'],
8485
[$.meta_property, $.import],
@@ -802,7 +803,11 @@ module.exports = grammar({
802803
call_expression: $ => choice(
803804
prec('call', seq(
804805
field('function', choice($.expression, $.import)),
805-
field('arguments', choice($.arguments, $.template_string)),
806+
field('arguments', $.arguments),
807+
)),
808+
prec('template_call', seq(
809+
field('function', choice($.primary_expression, $.new_expression)),
810+
field('arguments', $.template_string),
806811
)),
807812
prec('member', seq(
808813
field('function', $.primary_expression),

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
},
4545
"scripts": {
4646
"install": "node-gyp-build",
47+
"lint": "eslint grammar.js",
4748
"prestart": "tree-sitter build --wasm",
4849
"start": "tree-sitter playground",
4950
"test": "node --test bindings/node/*_test.js"

src/grammar.json

Lines changed: 35 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)