Skip to content

Commit

Permalink
parse curly braces as expression instead of directive
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinschweikert committed Dec 9, 2024
1 parent a5075e6 commit 25edee6
Show file tree
Hide file tree
Showing 6 changed files with 1,351 additions and 1,495 deletions.
35 changes: 20 additions & 15 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ module.exports = grammar({
fragment: ($) => repeat($._node),

_node: ($) =>
choice($.doctype, $.tag, $.component, $.text, $.comment, $.directive),
choice(
$.doctype,
$.tag,
$.component,
$.text,
$.comment,
$.directive,
$.expression
),

doctype: ($) => seq("<!", "DOCTYPE", "html", ">"),

Expand Down Expand Up @@ -117,21 +125,18 @@ module.exports = grammar({
),

directive: ($) =>
choice(
seq(
choice("<%", "<%=", "<%%", "<%%="),
prec.left(
seq(
choice(
$.partial_expression_value,
$.ending_expression_value,
$.expression_value
),
choice("%>")
)
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),
Expand Down
138 changes: 44 additions & 94 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 25edee6

Please sign in to comment.