Skip to content

"Zero or One" rule #47

Answered by foonathan
tomdavsmi asked this question in Q&A
Dec 15, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

You can use either dsl::if_() or dsl::opt() for that. The latter gives you a value when the rule didn't match, the former doesn't.

Although, if you're having a fixed list of symbols, it might make sense to use dsl::symbol: you specify a mapping of e.g. element names to enum values in a table, then read one of those.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tomdavsmi
Comment options

Answer selected by tomdavsmi
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