2
votes

I currently have:

start_ %= listrule_ | primrule_ ;

with start_'s attribute being a boost::variant, T> and primrule_'s attrib is T and listrule_'s attrib is std::vector.

This works because of spirit's "attrib propagation rule" I believe.

I want to add a 3rd possibility:

start_ %= listrule_ | primrule_ | '*';

and I want the '*' also to have std::vector, and I'll find a way to populate that vector with all the possible values of the enum T.

what's the syntax for attributing the '*' ?

this is in spirit 2, with c++11, boost 1.58

1

1 Answers

2
votes

Use the qi::attr directive

enum MyEnum { A, B, C, D, E };

start_ %= listrule_ 
        | primrule_ 
        | ('*' >> qi::attr(std::vector<MyEnum> { A, B, C, D, E })
        ;