-
I added the In this example I'd like to match either https://lexy.foonathan.net/playground/?id=KsjjTseno&mode=tree |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So I think there is a bit of a misunderstanding with Also, I didn't quite understand what you want, so here are possible interpretations:
(I've just now noticed that there is I should probably make the behavior in 3 the default, i.e. skip whitespace after error recovery; I haven't considered that situation before. |
Beta Was this translation helpful? Give feedback.
So I think there is a bit of a misunderstanding with
dsl::try_
: it is only used for error recovery. If you have a situation where a token is required by the grammar, but parsing can continue if it's omitted, you can usedsl::try_
for that. The error will still be reported, but instead of canceling the production, parsing can continue to check the rest of the input.Also,
dsl::opt(dsl::else_ >> x)
is never correct, as that is equivalent tox
:dsl::else_
is a branch rule that is unconditionally taken and is meant in combination with|
.I didn't quite understand what you want, so here are possible interpretations:
hello world
orhello::world
, where either is correct. Used…