Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. struct Parser: grammar<std::string::const_iterator, boost::spirit::ascii::space_type>
  2. {
  3. public:
  4. Parser(ConditionTree& a_lTree):
  5. Parser::base_type(limit_expression),
  6. m_lTree(a_lTree)
  7. {
  8. using boost::spirit::qi::uint_;
  9.  
  10. using boost::spirit::qi::_1;
  11. using boost::spirit::qi::_2;
  12.  
  13. limit_expression = limit_days_operator | limit_hours_operator | limit_minutes_operator ;
  14.  
  15. limit_days_operator = ( string("limit") > uint_ > string("days") )[ phoenix::bind( &ConditionTree::AddDaysLimitOperator, m_lTree, _2) ] ;
  16. limit_hours_operator = ( string("limit") > uint_ > string("hours") )[ phoenix::bind( &ConditionTree::AddHoursLimitOperator, m_lTree, _2) ] ;
  17. limit_minutes_operator = ( string("limit") > uint_ > string("minutes") )[ phoenix::bind( &ConditionTree::AddMinutesLimitOperator, m_lTree, _2) ] ;
  18.  
  19. BOOST_SPIRIT_DEBUG_NODE(limit_expression);
  20.  
  21. BOOST_SPIRIT_DEBUG_NODE(limit_days_operator);
  22. BOOST_SPIRIT_DEBUG_NODE(limit_hours_operator);
  23. BOOST_SPIRIT_DEBUG_NODE(limit_minutes_operator);
  24. }
  25.  
  26. rule<Iterator, space_type> limit_expression;
  27. rule<Iterator, space_type> limit_days_operator;
  28. rule<Iterator, space_type> limit_hours_operator;
  29. rule<Iterator, space_type> limit_minutes_operator;
  30.  
  31. ConditionTree& m_lTree;
  32. }
  33.  
  34.  
  35. void main()
  36. {
  37.  
  38. ConditionTree oTree;
  39.  
  40. Parser parser(oTree);
  41.  
  42. std::string strTest("limit5minutes");
  43.  
  44. std::string::const_iterator it_begin(strTest.begin());
  45. std::string::const_iterator it_end(strTest.end());
  46.  
  47. bool result = phrase_parse(it_begin, it_end, parser, space);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement