employee_def.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*=============================================================================
  2. Copyright (c) 2002-2018 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. =============================================================================*/
  6. #if !defined(BOOST_SPIRIT_X3_MINIMAL_EMPLOYEE_DEF_HPP)
  7. #define BOOST_SPIRIT_X3_MINIMAL_EMPLOYEE_DEF_HPP
  8. #include <boost/config/warning_disable.hpp>
  9. #include <boost/spirit/home/x3.hpp>
  10. #include "ast.hpp"
  11. #include "ast_adapted.hpp"
  12. #include "employee.hpp"
  13. namespace client
  14. {
  15. ///////////////////////////////////////////////////////////////////////////////
  16. // Our employee parser definition
  17. ///////////////////////////////////////////////////////////////////////////////
  18. namespace parser
  19. {
  20. namespace x3 = boost::spirit::x3;
  21. namespace ascii = boost::spirit::x3::ascii;
  22. using x3::int_;
  23. using x3::lit;
  24. using x3::double_;
  25. using x3::lexeme;
  26. using ascii::char_;
  27. x3::rule<class employee, ast::employee> const employee = "employee";
  28. auto const quoted_string = lexeme['"' >> +(char_ - '"') >> '"'];
  29. auto const employee_def =
  30. lit("employee")
  31. >> '{'
  32. >> int_ >> ','
  33. >> quoted_string >> ','
  34. >> quoted_string >> ','
  35. >> double_
  36. >> '}'
  37. ;
  38. BOOST_SPIRIT_DEFINE(employee);
  39. }
  40. parser::employee_type employee()
  41. {
  42. return parser::employee;
  43. }
  44. }
  45. #endif