c++ - Boost Spirit placeholder type conversion -


i'm trying write parser (as first step, of course expanded lot) parses double , creates object of class expressiontree passing double factory method of class. first try

struct operands : qi::grammar<string::iterator, expressiontree()>  {      operands() : operands::base_type(start)      {         start = qi::double_[qi::_val = expressiontree::number(qi::_1)];     }      qi::rule<string::iterator, expressiontree()> start;  }; 

this doesn't compile (can't convert boost::spirit::_1_type double) because (if understand correctly) qi::_1 not double evaluates double.

i tried using boost::bind(&expressiontree::number, _1) in way don't know how result assigned attribute _val

i grateful if point me in right direction.

you need lazy actors in semantic actions.

i'm assuming number static unary function or non-static nullary (instead of, e.g. type):

start = qi::double_ [ qi::_val = boost::phoenix::bind(&expressiontree::number, qi::_1)]; 

if type:

start = qi::double_ [ qi::_val = boost::phoenix::construct<expressiontree::number>(qi::_1)]; 

see also


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -