From a5075e6defe1e2382da955f6f4b6450da5af77b0 Mon Sep 17 00:00:00 2001 From: Kevin Schweikert <54439512+kevinschweikert@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:21:05 +0100 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit parse curly braces directive only with single expressions Co-authored-by: Jonatan KÅ‚osko --- grammar.js | 14 +------------- test/corpus/directives.txt | 7 +++++++ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/grammar.js b/grammar.js index d69f9d5..a4d9101 100644 --- a/grammar.js +++ b/grammar.js @@ -131,19 +131,7 @@ module.exports = grammar({ ) ) ), - seq( - choice("{"), - prec.left( - seq( - choice( - $.partial_expression_value, - $.ending_expression_value, - $.expression_value - ), - choice("}") - ) - ) - ) + alias($.expression, "expression") ), comment: ($) => choice($._html_comment, $._bang_comment, $._hash_comment), diff --git a/test/corpus/directives.txt b/test/corpus/directives.txt index 9007821..464a95e 100644 --- a/test/corpus/directives.txt +++ b/test/corpus/directives.txt @@ -47,7 +47,10 @@ Curly braces as directive
{ @message } + {@message} + {"#{1}"}
+ -------------------------------------------------------------------------------- (fragment @@ -56,5 +59,9 @@ Curly braces as directive (tag_name)) (directive (expression_value)) + (directive + (expression_value)) + (directive + (expression_value)) (end_tag (tag_name))))