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
Solved by @musikid: it needs to be choice!(attempt(x_parser), y_parser). I was looking at this documentation https://docs.rs/combine/4.6.0/combine/macro.choice.html which does not include any attempt - maybe a good idea to mention it there?
Also why does that example work, seeing as in the first assert, the first parser will fail, but it still works without attempt()?
That example works because it fails when looking at the first character, so it never consumes any input. It is thanks to this choice and similar parsers can produce error messages which hint to each alternative that was attempted. attempt makes a parser always work as if it consumed no input before it failed but it does this at the cost of making the error messages worse.
attempt ought to be linked in all parsers that tries alternatives, I actually thought it did already, maybe just in some of them.
Reproducible test case:
Prints:
I expected the last one to also be
Ok
because of how they_parser
can successfully parsey
The text was updated successfully, but these errors were encountered: