Replies: 1 comment 10 replies
-
|
Chumsky will try matching the input with each option in a choice until it finds one that parses the input. If none of them can successfully parse the input, the parser backtracks. If there are no other parsers 'higher up' in the parse tree that can parse the input, then an error will be produced.
It's not lazy, no (or, at least, it's allowed not to be). As mentioned here, closures should be 'conceptually pure' as chumsky can decide to optimise them away if it doesn't need to use them. If your parser state needs to support rollback on failure, you might want to use one of the non-standard state types like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When I have a choice with two parsers, and the first one does an intermediate
.map_with, so it's stateful, and then we.then(just("!"))which isn't what we read the that the first path "errors".Does this lead to the second choice not being evaluated (and if so, when is the point where this doesn't happen anymore?), or will the state now be in a weird state or is map_with lazy and only evaluated when it completely succeeded? And when yes, is order preserved?
Beta Was this translation helpful? Give feedback.
All reactions