1 #ifndef HLTrigger_HLTfilters_TriggerExpressionParser_h
2 #define HLTrigger_HLTfilters_TriggerExpressionParser_h
5 #include <boost/spirit/include/phoenix.hpp>
6 #include <boost/spirit/include/qi.hpp>
16 namespace qi = boost::spirit::qi;
17 namespace ascii = boost::spirit::ascii;
19 using boost::phoenix::new_;
20 using boost::spirit::unused_type;
22 template <
typename Iterator>
23 class Parser :
public qi::grammar<Iterator, Evaluator *(), ascii::space_type> {
26 token_l1algo %= qi::raw[qi::lexeme[
"L1_" >> +(qi::char_(
"a-zA-Z0-9_*?"))]];
27 token_path %= qi::raw[qi::lexeme[+(qi::char_(
"a-zA-Z0-9_*?"))]];
29 token = (qi::lit(
"TRUE")[qi::_val = new_<Constant>(
true)] | qi::lit(
"FALSE")[qi::_val = new_<Constant>(
false)] |
36 prescale = (
element >>
'/' >> qi::uint_)[qi::_val = new_<Prescaler>(qi::_1, qi::_2)];
40 unary = (
operand[qi::_val = qi::_1] | (qi::lit(
"NOT") >>
operand)[qi::_val = new_<OperatorNot>(qi::_1)]);
43 unary[qi::_val = qi::_1] >> *((qi::lit(
"AND") >>
unary)[qi::_val = new_<OperatorAnd>(qi::_val, qi::_1)] |
44 (qi::lit(
"OR") >>
unary)[qi::_val = new_<OperatorOr>(qi::_val, qi::_1)]);
66 typedef typename T::const_iterator
Iterator;
74 bool result = qi::phrase_parse(begin,
end,
parser, ascii::space, evaluator);
89 const char *begin =
text;
93 bool result = qi::phrase_parse(begin,
end,
parser, ascii::space, evaluator);
105 #endif // HLTrigger_HLTfilters_TriggerExpressionParser_h