x3::rule<class term, ast::program> const term("term");
x3::rule<class factor, ast::operand> const factor("factor");
- BOOST_SPIRIT_DEFINE(
- expression =
+ auto const expression_def =
term
>> *( (char_('+') >> term)
| (char_('-') >> term)
)
- ,
+ ;
- term =
+ auto const term_def =
factor
>> *( (char_('*') >> factor)
| (char_('/') >> factor)
)
- ,
+ ;
- factor =
+ auto const factor_def =
uint_
| '(' >> expression >> ')'
| (char_('-') >> factor)
| (char_('+') >> factor)
- );
+ ;
+
+ BOOST_SPIRIT_DEFINE(expression, term, factor);
auto calculator = expression;
}