OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
file_def.hpp
Go to the documentation of this file.
1 //
2 // Struct file
3 //
4 // Copyright (c) 2015, Christof Metzger-Kraus, Helmholtz-Zentrum Berlin
5 // All rights reserved
6 //
7 // This file is part of OPAL.
8 //
9 // OPAL is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
16 //
17 #ifndef FILE_DEF_HPP_
18 #define FILE_DEF_HPP_
19 
20 #include "file.hpp"
21 
22 #include <boost/spirit/include/phoenix_core.hpp>
23 #include <boost/spirit/include/phoenix_operator.hpp>
24 #include <boost/spirit/include/phoenix_fusion.hpp>
25 #include <boost/spirit/include/phoenix_stl.hpp>
26 #include <boost/spirit/include/phoenix_object.hpp>
27 #include <boost/spirit/include/phoenix_bind.hpp>
28 
29 namespace SDDS { namespace parser
30 {
31  template <typename Iterator>
32  file_parser<Iterator>::file_parser(error_handler<Iterator> & _error_handler):
33  file_parser::base_type(start),
34  version_m(_error_handler),
35  description_m(_error_handler),
36  parameter_m(_error_handler),
37  column_m(_error_handler),
38  data_m(_error_handler),
39  associate_m(_error_handler),
40  array_m(_error_handler),
41  include_m(_error_handler)
42  {
43  using qi::on_error;
44  using qi::on_success;
45  using qi::fail;
46  using phx::function;
47  typedef function<error_handler<Iterator> > error_handler_function;
48 
49  qi::_1_type _1;
50  qi::_3_type _3;
51  qi::_4_type _4;
52  qi::_val_type _val;
53  qi::skip_type skip;
54 
55  auto push_backParameter = phx::push_back(phx::at_c<2>(_val), _1);
56  auto push_backColumn = phx::push_back(phx::at_c<3>(_val), _1);
57  auto push_backAssociate = phx::push_back(phx::at_c<5>(_val), _1);
58  auto push_backArray = phx::push_back(phx::at_c<6>(_val), _1);
59  auto push_backInclude = phx::push_back(phx::at_c<7>(_val), _1);
60 
61  start =
62  version_m[phx::at_c<0>(_val) = _1]
63  > -description_m[phx::at_c<1>(_val) = _1]
64  > *(parameter_m[push_backParameter]
65  | column_m[push_backColumn]
66  | associate_m[push_backAssociate]
67  | array_m[push_backArray]
68  | include_m[push_backInclude]
69  )
70  > data_m[phx::at_c<4>(_val) = _1]
71  ;
72 
73  BOOST_SPIRIT_DEBUG_NODES(
74  (start)
75  )
76 
77  on_error<fail>(start,
78  error_handler_function(_error_handler)(
79  std::string("Error! Expecting "), _4, _3));
80 
81  }
82 }}
83 #endif /* FILE_DEF_HPP_ */
Definition: array.hpp:33