Hello all,
I want to write a const-expression parser which calculate the result
while parsing. When do it with double and int, I don't know how to do,
my code like:
namespace b=boost;
namespace bs=boost::spirit;
namespace bsq=boost::spirit::qi;
namespace bp=boost::phoenix;
bsq::real_parser bnf_double;
bsq::int_parser bnf_int8;
bsq::int_parser bnf_int10;
bsq::int_parser bnf_int16;
template <typename Iterator>
struct const_expression: bsq::grammar()>
{
typedef b::variant result_type;
const_expression() : const_expression::base_type(rstart)
{
using bsq::_val;
using bsq::_1;
using bsq::_a;
result_type result;
rstart =
bnf_double[_val=_1] >>
*(
bsq::lit('+') >> bnf_double[how to write here]
)
| rint [_val=_1]
;
rint =
bsq::lit('0') >> bsq::char_("xX") >> bnf_int16[_val=_1]
| bsq::lit('0') >> bnf_int8[_val=_1]
| bnf_int10[_val=_1]
;
}
bsq::rule rstart;
bsq::rule rint;
};
Thanks
yours