My goal is to have my qi::grammar return an attribute. I\'m having significant difficulty doing this with a spirit::lexer though.
I\'d expe
I ended up realizing that the struct I defined is being used in spirit as a tuple. Because spirit will try to minimize the groups (like, an optional is an optional). Therefore, I guessed that a tuple will be converted to an A. Which seems to be the case.
I was able to further reduce the test case of broken code to the following:
#include
#include
#include
struct ident {
std::string a;
};
BOOST_FUSION_ADAPT_STRUCT(ident,
(std::string, a)
)
int main() {
boost::spirit::qi::rule r;
r = boost::spirit::lexeme["abc"];
}
From the following mailing list postings (1, 2) that I found, I can work around this issue by doing:
r = boost::spirit::lexeme["abc"] >> boost::spirit::eps;
While not really elegant, it solves the problem at least. If someone else has a method to do the single element struct, I'd be greatly interested though.