Skip to content

Commit

Permalink
Change structure of attribute values
Browse files Browse the repository at this point in the history
  • Loading branch information
kolen committed Jul 4, 2024
1 parent 4c61bb3 commit b7f57dd
Show file tree
Hide file tree
Showing 8 changed files with 2,468 additions and 2,528 deletions.
18 changes: 9 additions & 9 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = grammar({
$._block_end,
$._line_separator,

$._attr_value_quoted,
$.attr_value_quoted,
$._attr_value_ruby,
$._attr_value_ruby_p, // ()
$._attr_value_ruby_s, // []
Expand Down Expand Up @@ -129,13 +129,13 @@ module.exports = grammar({

return {
[`_attr_delimited_value_${suffix}`]: $ => choice(
$._attr_value_quoted,
alias($[`_attr_value_ruby_${suffix}`], $.ruby_expr)
$.attr_value_quoted,
alias($[`_attr_value_ruby_${suffix}`], $.attr_value_ruby)
),

[`_attr_delimited_splat_${suffix}`]: $ => seq(
'*',
alias($[`_attr_value_ruby_${suffix}`], $.ruby_expr)
$[`_attr_value_ruby_${suffix}`]
),

[`_attr_delimited_${suffix}`]: $ => choice(
Expand All @@ -144,7 +144,7 @@ module.exports = grammar({
seq(
field('name', $.attr_name),
field('assignment', choice($.attr_assignment, $.attr_assignment_noescape)),
field('value', alias($[`_attr_delimited_value_${suffix}`], $.attr_value))
field('value', $[`_attr_delimited_value_${suffix}`])
)
),

Expand All @@ -166,16 +166,16 @@ module.exports = grammar({
seq(
field('name', $.attr_name),
field('assignment', choice($.attr_assignment, $.attr_assignment_noescape)),
field('value', $.attr_value),
field('value', $._attr_value),
),
),
attr_name: $ => $._attr_name,
_attr_name: $ => token(prec(-2, /[^ \t\n\\0\"\'></=()\[\]{}]+/)),
attr_assignment: $ => /[ \t]*=[ \t]*/,
attr_assignment_noescape: $ => /[ \t]*==[ \t]*/,
attr_value: $ => choice(
$._attr_value_quoted,
alias($._attr_value_ruby, $.ruby_expr)
_attr_value: $ => choice(
$.attr_value_quoted,
alias($._attr_value_ruby, $.attr_value_ruby)
// TODO: many more
),
attr_boolean: $ => $.attr_name,
Expand Down
5 changes: 4 additions & 1 deletion queries/injections.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
((ruby) @injection.content
(#set! injection.language "ruby"))

((ruby_expr) @injection.content
((attr_value_ruby) @injection.content
(#set! injection.language "ruby"))

((attr_splat) @injection.content
(#set! injection.language "ruby"))
76 changes: 23 additions & 53 deletions src/grammar.json

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

47 changes: 15 additions & 32 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 b7f57dd

Please sign in to comment.