OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
include_def.hpp
Go to the documentation of this file.
1 //
2 // Struct include
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 INCLUDE_DEF_HPP_
18 #define INCLUDE_DEF_HPP_
19 
20 #include "include.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_bind.hpp>
26 
27 namespace SDDS { namespace parser
28 {
29  template <typename Iterator>
31  include_parser::base_type(start)
32  {
33  using qi::on_error;
34  using qi::fail;
35  using phx::function;
36  typedef function<error_handler<Iterator> > error_handler_function;
37 
38  qi::_3_type _3;
39  qi::_4_type _4;
40  qi::lexeme_type lexeme;
41  qi::char_type char_;
42  qi::lit_type lit;
43  qi::alpha_type alpha;
44  qi::alnum_type alnum;
45  qi::_pass_type _pass;
46 
47  quoted_string %= lexeme['"' >> +(char_ - '"') >> '"'];
48  string %= quoted_string
49  | lexeme[(alpha | '_') >> *(alnum | '_')];
50 
51  include_filename = lit("filename") > '=' > string;
52 
53  auto complainInclude = phx::bind(&include::complainUnsupported<include::INCLUDE>::apply);
54 
55  start =
56  lit("&include")[_pass = complainInclude]
57  > lit("&end");
58 
59  BOOST_SPIRIT_DEBUG_NODES(
60  (start)
61  )
62 
63  on_error<fail>(start,
64  error_handler_function(_error_handler)(
65  std::string("Error! Expecting "), _4, _3));
66  }
67 }}
68 #endif /* INCLUDE_DEF_HPP_ */
constexpr double alpha
The fine structure constant, no dimension.
Definition: Physics.h:78
Definition: array.hpp:33
qi::rule< Iterator, include(), skipper< Iterator > > start
Definition: include.hpp:85
include_parser(error_handler< Iterator > &_error_handler)
Definition: include_def.hpp:30
qi::rule< Iterator, std::string(), skipper< Iterator > > include_filename
Definition: include.hpp:87
qi::rule< Iterator, std::string(), skipper< Iterator > > quoted_string
Definition: include.hpp:86
qi::rule< Iterator, std::string(), skipper< Iterator > > string
Definition: include.hpp:86