You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unlike manyTill p endp, many1Till p endp runs p first, even if endp would match immediately. This, when used in a recursive grammar, can cause parsers that work perfectly fine on most inputs to produce stack overflows - despite a modest recursion depth of <10, and can cause inputs of reasonable length to stall for long / indefinite periods (I think O(n!)).
The documentation currently reads:
The parser many1Till p endp behaves like manyTill p endp, except that it requires p to succeed at least one time.
many1Till p endp is an optimized implementation of pipe2 p (manyTill p endp) (fun hd tl -> hd::tl)
I would suggest that many1Till (and skipMany1Till) be changed to the equivalent of notFollowedBy endp >>. many1Till p endp. If that behavior change is not wanted, I'd strongly recommend documenting this quirk in a more obvious way, and with a disclaimer that this can cause problems with recursive grammars.
I'm also not sure if similar issues exist in other primitives - this is the only one I've encountered so far.
The text was updated successfully, but these errors were encountered:
Unlike
manyTill p endp
,many1Till p endp
runsp
first, even ifendp
would match immediately. This, when used in a recursive grammar, can cause parsers that work perfectly fine on most inputs to produce stack overflows - despite a modest recursion depth of <10, and can cause inputs of reasonable length to stall for long / indefinite periods (I thinkO(n!)
).The documentation currently reads:
I would suggest that
many1Till
(andskipMany1Till
) be changed to the equivalent ofnotFollowedBy endp >>. many1Till p endp
. If that behavior change is not wanted, I'd strongly recommend documenting this quirk in a more obvious way, and with a disclaimer that this can cause problems with recursive grammars.I'm also not sure if similar issues exist in other primitives - this is the only one I've encountered so far.
The text was updated successfully, but these errors were encountered: