Skip to content

Q: how to restrict a rule #45

Answered by d-frey
cppden asked this question in Q&A
Discussion options

You must be logged in to vote

You could use nested if_then_else rules, e.g.

if_then_else< istring<'a','='>, digit,
if_then_else< istring<'b','='>, alpha,
param_other > >

which is strangely formatted when it comes to nesting and which leaves the question of where to attach the actions. But from a pure parsing POV, it will do exactly what you need.

I think we could also easily build a better interface, maybe a "sequenced switch" with an interface like

sswitch< istring<'a','='>, digit,
         istring<'b','='>, alpha,
         param_other >

and maybe allow specializing on sswitch_case<istring<'a','='>> for the actions and passing the whole matching input of the case. @ColinH What do you think?

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by d-frey
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #45 on December 09, 2020 10:50.