0

I have checked this webpage http://www.boost.org/doc/libs/1_44_0/libs/spirit/doc/html/spirit/qi/quick_reference/compound_attribute_rules.html, and many others, but couldn't find an answer to my question.

I have a rule of the form C %= A % B, where B is a parser and NOT a literal, and it is of different type than A. The rule given on the webpage above says:

a: A, b: B --> (a % b): vector<A>

but given that in my case B is a parser and not of type A this rule doesn't seem to do the trick.

I have tried out this:

(a % b): variant<A, tuple<B,A>>

and as a consequence defined this structure:

    struct equality_expression
    {
        variant<A,tuple<B,A>> equexp;
    };

and thereafter

    BOOST_FUSION_ADAPT_STRUCT(
        equality_expression,
        (variant<A,tuple<B,A>>, equexp);
    )

but the compiler complains:

warning C4002: too many actual parameters for macro 'BOOST_FUSION_ADAPT_STRUCT_FILLER_0'

So, what's the correct way of doing this?

ildjarn
  • 62,044
  • 9
  • 127
  • 211
Sakuragaoka
  • 177
  • 1
  • 8

1 Answers1

2

The way to read a: A, b: B --> (a % b): vector<A> is: "if parser a exposes an attribute A and parser b exposes an attribute B then a%b exposes the attribute vector<A>", meaning that the attribute of B is always ignored in the list parser. The problem with your macro invocation are the commas that separate the template parameters.

Community
  • 1
  • 1
llonesmiz
  • 155
  • 2
  • 11
  • 20