Skip to content

Commit

Permalink
fix: don't allow whitespace between selector-expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
qvalentin committed May 2, 2024
1 parent 17144a7 commit 581d886
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
5 changes: 3 additions & 2 deletions make_grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,9 @@ module.exports = function make_grammar(dialect) {
prec(
PREC.primary,
seq(
field('operand', $._pipeline),
'.',
field('operand',
choice($.parenthesized_pipeline, $.field, $.variable, $.selector_expression)),
token.immediate('.'),
field('field', $._field_identifier)
)
),
Expand Down
13 changes: 13 additions & 0 deletions test/corpus/arguments.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,16 @@ Named variable with chained field
(identifier))
(field_identifier))
(field_identifier)))

====================================
Two fields seperated by whitespace / method call with field as argument
====================================
{{ .Field .Field }}
---
(template
(method_call
(field
(identifier))
(argument_list
(field
(identifier)))))
12 changes: 12 additions & 0 deletions test/corpus/pipelines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,15 @@ Method on a field with arguments
(identifier))
(field_identifier))
(int_literal))))

====================================
Selector expression on a parenthesized pipeline
====================================
{{ (pipeline).Field }}
---
(template
(selector_expression
(parenthesized_pipeline
(function_call
(identifier)))
(field_identifier)))

0 comments on commit 581d886

Please sign in to comment.