-
I have issue with this grammar:
This doesn't work and don't give any error. It works when the group is in separated rule. You can test the grammar on this CodePen demo: https://codepen.io/jcubic/pen/zYLvPQa?editors=1000 If you add $ and replace text.join('') with text, the parser just output input text. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
This works as designed at the moment. Changing it would break existing grammars. This comes up most often for me in grammars that decode things like escaped quotes: string
= DQUOTE s:char* DQUOTE {
return s.join('');
}
DQUOTE
= '"'
char
= ![\\"] @. // Anything but backslash or dquote
/ '\\' @'"' The docs say:
Which makes it pretty clear that |
Beta Was this translation helpful? Give feedback.
Here's a simplified example:
The input "barbar" will give the output
['baz', 'baz']
.When you change Foo to be
$bar+
, the output is"barbar"
. The$
discards whatever thebar
rule returns and instead returns matching text. Thebar
rule still runs twice, still matches twice.