Question

When I use this qi grammar accepting tokens from Lex:

pair %=  token(ID_MARKER)
    >> ':'
    >> atom
    >> ','
    >> atom
    ;

in conjunction with this fusion/tuple mapping to assist in the capture:

BOOST_FUSION_ADAPT_STRUCT(
    Client::pair_rec,
    (std::string,      m_dummy  )  // want to rid of this capture of ID_MARKER
    (Client::atom_rec, m_atom_1 )
    (Client::atom_rec, m_atom_2 )
)

everything works fine.

But I would like to use the ID_MARKER just for parsing; I don't really need or want to capture it.

So I tried to ignore the attribute by using qi::lit:

pair %=  qi::lit( token(ID_MARKER) )
    >> ':'
    >> atom
    >> ','
    >> atom
    ;

along with removing m_dummy from the capture, but I just get a wall of template errors.

What should I be doing instead, to clean this up?

Was it helpful?

Solution

Without code to test I can't be sure, but:

pair %=  qi::omit[ token(ID_MARKER) ]
    >> ':'
    >> atom
    >> ','
    >> atom
    ;

should work. You could also add a token_def<lex::omit> marker; in your lexer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top