-
Hello, Now; i have some stuff where I have not found solution/answer so far; here is a first one From the documentation , i am trying to solve the case where for example 'b' is mandatory; 'a' and 'c' optional.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
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 |
Beta Was this translation helpful? Give feedback.
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.