I have the following boost::spirit::qi parser rule:
namespace qi = boost::spirit::qi;
qi::rule<Iterator, BroadbandCurve(), Skipper> Cmd_BBNSET;
Cmd_BBNSET = +(qi::float_ >> qi::float_) >> qi::int_ >> qi::int_ >> lit("BBNSET");
I'm trying to get it to emit the following attribute:
struct FreqLevelPair
{
float freq;
float dbLevel;
};
BOOST_FUSION_ADAPT_STRUCT(
FreqLevelPair,
(float, freq)
(float, dbLevel)
)
struct BroadbandCurve
{
std::vector<FreqLevelPair> freqPairs;
int numFreqPairs; //Ignored since we can just count the number of pairs outright...
int curveNum; //ID number
};
BOOST_FUSION_ADAPT_STRUCT(
BroadbandCurve,
(std::vector<FreqLevelPair>, freqPairs)
(int, numFreqPairs)
(int, curveNum)
)
As you can see, I'm attempting to parse one or more pairs of floats, followed by two ints, followed by the literal "BBNSET." All of this code compiles, however when I attempt to parse a valid BBNSET command of the form:
0.0 80.0 50.0 25.0 100.0 10.0 3 0 BBNSET
the parse fails. I'm unable to determine why. I've attempted wrapping the float pairs in a lexeme directive, and changing the + to a *, but no matter what I've attempted, the command still fails to parse, despite compiling without a problem.
What am I doing wrong, and will this rule emit the attribute as expected once it is parsing correctly?