Skip to content

Commit

Permalink
tree-sitter: improve selector expression grammar
Browse files Browse the repository at this point in the history
* cleanup
  • Loading branch information
ttytm committed Mar 31, 2024
1 parent f0808e7 commit 879357c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tree_sitter_v/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,6 @@ module.exports = grammar({

as_type_cast_expression: ($) => seq($._expression, 'as', $.plain_type),

compile_time_selector_expression: ($) =>
seq('$', seq('(', choice($.reference_expression, $.selector_expression), ')')),

or_block: ($) => seq('or', field('block', $.block)),

_max_group: ($) => prec.left(PREC.resolve, choice($.pseudo_compile_time_identifier, $.literal)),
Expand Down Expand Up @@ -695,6 +692,13 @@ module.exports = grammar({
),
),

compile_time_selector_expression: ($) =>
seq(
token.immediate('$('),
field('field', choice($.reference_expression, $.selector_expression)),
')',
),

index_expression: ($) =>
prec.dynamic(
-1,
Expand Down Expand Up @@ -1247,10 +1251,7 @@ function sep(rule) {
*
*/
function stringBody(re, $) {
return choice(
token.immediate(prec.right(1, re)),
choice($.escape_sequence, $.string_interpolation),
);
return choice(token.immediate(prec.right(1, re)), $.escape_sequence, $.string_interpolation);
}

/**
Expand Down

0 comments on commit 879357c

Please sign in to comment.