-
I'm not sure if this is a bug or if I'm just misunderstanding how
I'd expect
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, this is the expected behavior.
If you want to make something optional, use either (Maybe the name |
Beta Was this translation helpful? Give feedback.
Yes, this is the expected behavior.
dsl::try_()
is used to do error recovery: if an error happens, it is still reported, but parsing continues after doing the optional recovery part: https://lexy.foonathan.net/playground/?id=7zf1WG4oGIf you want to make something optional, use either
dsl::if_(branch)
, which parses the branch if the condition matches, and does nothing otherwise, ordsl::opt_(branch)
, which produces a speciallexy::nullopt
value if the branch was not taken: https://lexy.foonathan.net/playground/?id=G1ndY9jrb(Maybe the name
dsl::try_()
isn't ideal)