I think there is a discrepancy between the documentation for repetitions in conjunction with code blocks and results of preceding labeled expressions and the actual behavior.
In particular the statement
Any non-number values, returned by the code block, will be interpreted as 0.
seems to be wrong.
A grammar like:
start = text:"a"|{ return 'some string' }|
does not return a number and hence should be equivalent to
start = text:"a"|0|
However, the parser accepts infinite input of "a".
Hi all,
I think there is a discrepancy between the documentation for repetitions in conjunction with code blocks and results of preceding labeled expressions and the actual behavior. In particular the statement
seems to be wrong. A grammar like:
does not return a number and hence should be equivalent to
However, the parser accepts infinite input of "a".
This is probably due to the following lines, in particular
|0
and the operator precedence?: https://github.com/peggyjs/peggy/blob/d2f5bb928f5dbd7759e7d41601ea300e161fc362/lib/compiler/passes/generate-js.js#L490-L496Any clarification is appreciated.