Skip to content

How to use dsl::partial_combination and specifiying that some branch are mandatory #185

Answered by foonathan
sandwoodK asked this question in Q&A
Discussion options

You must be logged in to vote

This isn't possible using the existing combinators and I don't want to complicate them as much, as I think it is a somewhat niche feature, and if I start adding that, you might also want to parse something between n-m times but only if X is not parsed, etc.

If you don't want to do validation afterwards, which I would really recommend - it is a semantic error, not a parse error, and if the parser accepts as much as possible, you can do better error messages during semantic validation, you can use a lexy::scan_production: https://lexy.foonathan.net/playground/?id=sq9TY9P17&mode=tree You can then implement whatever logic you want, albeit more verbosely.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by foonathan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants