Skip to content

Returning a constant on a match #144

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

You must be logged in to vote

The compilation error here is because opt(dsl::p<has_colon>) returns true or lexy::nullopt, but there is no way to construct unit from lexy::nullopt.

The whitespace issue is because after you skip whitespace, you expect a colon, and don't have a way to parse whitespace without a colon. I don't understand why you can't use automatic whitespace skipping. Is whitespace only relevant in some parts of your grammars and not in others? Because otherwise, it's enough to add a whitespace member to the root production and have it propagate through. That way, you don't have to worry about it at all.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DiKetarogg
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