OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
description_def.hpp
Go to the documentation of this file.
1 //
2 // Copyright & License: See Copyright.readme in src directory
3 //
4 
9 #ifndef DESCRIPTION_DEF_HPP_
10 #define DESCRIPTION_DEF_HPP_
11 
12 #include "description.hpp"
13 
14 #include <boost/spirit/include/phoenix_core.hpp>
15 #include <boost/spirit/include/phoenix_operator.hpp>
16 #include <boost/spirit/include/phoenix_fusion.hpp>
17 #include <boost/spirit/include/phoenix_bind.hpp>
18 
19 namespace SDDS { namespace parser
20 {
21  template <typename Iterator>
22  description_parser<Iterator>::description_parser(error_handler<Iterator> & _error_handler):
23  description_parser::base_type(start)
24  {
25  using qi::on_error;
26  using qi::fail;
27  using phx::function;
28  typedef function<error_handler<Iterator> > error_handler_function;
29 
30  qi::_1_type _1;
31  qi::_3_type _3;
32  qi::_4_type _4;
33  qi::lexeme_type lexeme;
34  qi::lit_type lit;
35  qi::char_type char_;
36  qi::_val_type _val;
37 
38  quoted_string %= lexeme['"' >> +(char_ - '"') >> '"'];
39  description_text = lit("text") > '=' > quoted_string;
40  description_content = lit("contents") > '=' > quoted_string;
41 
42  start =
43  lit("&description")
44  > ((description_text[phx::at_c<0>(_val) = _1]
45  > -(',' > description_content[phx::at_c<1>(_val) = _1]))
46  |(description_content[phx::at_c<1>(_val) = _1]
47  > -(',' > description_text[phx::at_c<0>(_val) = _1])))
48  > lit("&end");
49 
50  BOOST_SPIRIT_DEBUG_NODES(
51  (start)
52  )
53 
54  on_error<fail>(start,
55  error_handler_function(_error_handler)(
56  std::string("Error! Expecting "), _4, _3));
57  }
58 }}
59 #endif /* DESCRIPTION_DEF_HPP_ */