OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
file_def.hpp
Go to the documentation of this file.
1 //
2 // Copyright & License: See Copyright.readme in src directory
3 //
4 
9 #ifndef FILE_DEF_HPP_
10 #define FILE_DEF_HPP_
11 
12 #include "file.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_stl.hpp>
18 #include <boost/spirit/include/phoenix_object.hpp>
19 #include <boost/spirit/include/phoenix_bind.hpp>
20 
21 namespace SDDS { namespace parser
22 {
23  template <typename Iterator>
24  file_parser<Iterator>::file_parser(error_handler<Iterator> & _error_handler):
25  file_parser::base_type(start),
26  version_m(_error_handler),
27  description_m(_error_handler),
28  parameter_m(_error_handler),
29  column_m(_error_handler),
30  data_m(_error_handler),
31  associate_m(_error_handler),
32  array_m(_error_handler),
33  include_m(_error_handler)
34  {
35  using qi::on_error;
36  using qi::on_success;
37  using qi::fail;
38  using phx::function;
39  typedef function<error_handler<Iterator> > error_handler_function;
40 
41  qi::_1_type _1;
42  qi::_3_type _3;
43  qi::_4_type _4;
44  qi::_val_type _val;
45  qi::skip_type skip;
46 
47  auto push_backParameter = phx::push_back(phx::at_c<2>(_val), _1);
48  auto push_backColumn = phx::push_back(phx::at_c<3>(_val), _1);
49  auto push_backAssociate = phx::push_back(phx::at_c<5>(_val), _1);
50  auto push_backArray = phx::push_back(phx::at_c<6>(_val), _1);
51  auto push_backInclude = phx::push_back(phx::at_c<7>(_val), _1);
52 
53  start =
54  version_m[phx::at_c<0>(_val) = _1]
55  > -description_m[phx::at_c<1>(_val) = _1]
56  > *(parameter_m[push_backParameter]
57  | column_m[push_backColumn]
58  | associate_m[push_backAssociate]
59  | array_m[push_backArray]
60  | include_m[push_backInclude]
61  )
62  > data_m[phx::at_c<4>(_val) = _1]
63  ;
64 
65  BOOST_SPIRIT_DEBUG_NODES(
66  (start)
67  )
68 
69  on_error<fail>(start,
70  error_handler_function(_error_handler)(
71  std::string("Error! Expecting "), _4, _3));
72 
73  }
74 }}
75 #endif /* FILE_DEF_HPP_ */