Possible Duplicate:
I can’t get Boost Spirit Lex and Qi to work together when qi returns an attribute
I've got a pretty simple problem that I can't seem to figure out. I won't bother posting the full code because I'm pretty sure that you won't need to see it to know want the problem is.
Lets say I want to parse a file that looks like this:
"dp",1,1
"dp",2,2
You want each data line to be a struct and put them into a vector.
namespace node {
struct dp { int a; int b; };
std::vector<dp> data;
}
I add them to Fusion.
BOOST_FUSION_ADAPT_STRUCT(obj::dp,(int,a)(int,b))
BOOST_FUSION_ADAPT_STRUCT(node::data,(std::vector<node::dp>,data))
My parsing grammar looks like this:
_dp %= lit("\"dp\",") >> int >> ',' >> int;
_d %= *_dp;
My rules are:
// in node namespace
qi::rule<Iterator,data(),Skipper> _d;
qi::rule<Iterator,dp(),Skipper> _dp;
The problem is that...
_d %= *_dp;
Doesn't compile, but if I put anything in front of it, it does.
_d %= 'a' >> *_dp;
Of coarse this won't parse because the input data doesn't have an 'a' but you get the point.
How would you handle something like this?