I'm trying to write an expression parser with boost spirit x3. I based my new code on old code that I written years ago (and worked well) with Spirit 2.x (qi).
The core of my code is:
//Make new rule(s) for expression
auto term = factor >> *(('*' >> factor) | ('/' >> factor));
auto expression = term >> *(('+' >> term) | ('-' >> term));
auto group = '(' >> expression >> ')';
auto factor = lexeme["double_"] | group;
string s="12.4 + 3.2";
auto first = s.begin();
auto last = s.end();
bool r = x3::phrase_parse(
first,
last,
// Begin grammar
expression,
// End grammar
x3::space);
I obtain two errors (Visual Studio 2019): Error C2338 BOOST_SPIRIT_DEFINE undefined for this rule. Error C2039 'parse': is not a member of 'boost::spirit::x3::unused_type'
Why?
Aucun commentaire:
Enregistrer un commentaire