Skip to content

Commit

Permalink
Support for custom syntax '???'
Browse files Browse the repository at this point in the history
closes #39
  • Loading branch information
moetelo committed Nov 16, 2024
1 parent b88c97b commit 95079d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/tree-sitter-twig/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,22 @@ Ternary operator short
(variable)
(string))))

==================
Empty Coalesce
==================
{% set choice = thingOne ??? thingTwo ??? thingThree ??? thingFour %}
---
(template
(set
(variable)
(binary_expression
(variable)
(binary_expression
(variable)
(binary_expression
(variable)
(variable))))))

==================
Filter without arguments
==================
Expand Down
1 change: 1 addition & 0 deletions packages/tree-sitter-twig/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ module.exports = grammar({
['is same as', 100],
['**', 200, 'right'],
['??', 300, 'right'],
['???', 300, 'right'], // https://nystudio107.com/docs/empty-coalesce
]).map(([operator, precedence, associativity = 'left']) =>
prec[associativity](
precedence,
Expand Down

0 comments on commit 95079d6

Please sign in to comment.