diff --git a/packages/tree-sitter-twig/corpus/expressions.txt b/packages/tree-sitter-twig/corpus/expressions.txt index b178b29..6916318 100644 --- a/packages/tree-sitter-twig/corpus/expressions.txt +++ b/packages/tree-sitter-twig/corpus/expressions.txt @@ -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 ================== diff --git a/packages/tree-sitter-twig/grammar.js b/packages/tree-sitter-twig/grammar.js index 11da2a3..16eac6f 100644 --- a/packages/tree-sitter-twig/grammar.js +++ b/packages/tree-sitter-twig/grammar.js @@ -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,