-
-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
or combinator prefers output of second parser, even if first parser succeeds #567
Comments
for clarity: removing |
Do you have a more complete example that I can run locally? I don't see anything wrong here, but the behaviour of |
This is the src file for tokenizer and ast. |
I've not had time to properly look at this yet, but have you considered moving to |
That depends on how stable the new API is currently. If it's unlikely to change significantly, I'm willing to try it, but otherwise id rather stay with 0.9 |
Would you recommend the alpha release or the GitHub main branch? |
1.0 is almost ready. There is more work to be done, but it's largely around docs & minor cleanups (see #543). In all likelihood, the worst breaking change you might expect from here on out might be something like a method being renamed: the API as it sits today will remain pretty much unchanged come 1.0 stable, all of the core concepts & features are in place and aren't going anywhere.
|
is there an easy way to recreate the take_until function from 0.9.3 in 1.0.0 alpha 6? |
Yes, check out any().and_is(ending.not()).repeated() Where |
The bug persists after I upgraded to chumsky alpha 6 |
Could It have something to do with the fact that ast_parser is a recursive parser that in its body calls the html parser again? |
It's not a bug in Chumsky, but with your parser. If you put a
From this we can determine that your |
damn you're right. Thank you! |
instead of let ast_non_html = choice((block(ast_parser), flat()))
.repeated()
.collect::<AST>(); |
In the code snippet below, I am trying to parse a tree structure, where something can be either a node (an html string, a piece of template code and then another html string) or a leaf (just an html string). I try to parse a node first and if that fails try parsing a leaf, but the or combinator seems to prefer the output of the leaf parser, even if the node parser succeeds. I tested this by removing the or combinator and testing the node parser on the exact same input, which does produce the desired result:
Test code and result
The text was updated successfully, but these errors were encountered: