OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
associate_def.hpp
Go to the documentation of this file.
1 //
2 // Struct associate
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 ASSOCIATE_DEF_HPP_
18 #define ASSOCIATE_DEF_HPP_
19 
20 #include "associate.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  associate_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::_1_type _1;
39  qi::_3_type _3;
40  qi::_4_type _4;
41  qi::lexeme_type lexeme;
42  qi::char_type char_;
43  qi::lit_type lit;
44  qi::long_type long_;
45  qi::short_type short_;
46  qi::alpha_type alpha;
47  qi::alnum_type alnum;
48  // qi::_val_type _val;
49  qi::_pass_type _pass;
50  qi::eps_type eps;
51 
52  quoted_string %= lexeme['"' >> +(char_ - '"') >> '"'];
53  string %= quoted_string
54  | lexeme[(alpha | '_') >> *(alnum | '_')];
55 
56  associate_name = lit("mode") > '=' > string;
57  associate_filename = lit("filename") > '=' > string;
58  associate_path = lit("path") > '=' > string;
59  associate_description = lit("description") > '=' > string;
60  associate_contents= lit("contents") > '=' > string;
61  associate_sdds= lit("column_major_order") > '=' > long_;
62 
63  auto complainAssociate = phx::bind(&associate::complainUnsupported<associate::ASSOCIATE>::apply);
64  auto complainName = phx::bind(&associate::complainUnsupported<associate::NAME>::apply);
65  auto complainFilename = phx::bind(&associate::complainUnsupported<associate::FILENAME>::apply);
66  auto complainPath = phx::bind(&associate::complainUnsupported<associate::PATH>::apply);
67  auto complainDescription = phx::bind(&associate::complainUnsupported<associate::DESCRIPTION>::apply);
68  auto complainContents = phx::bind(&associate::complainUnsupported<associate::CONTENTS>::apply);
69  auto complainSDDS = phx::bind(&associate::complainUnsupported<associate::SDDS>::apply);
70 
72  ((',' > associate_name[_pass = complainName])
73  ^ (',' > associate_filename[_pass = complainFilename])
74  ^ (',' > associate_path[_pass = complainPath])
75  ^ (',' > associate_description[_pass = complainDescription])
76  ^ (',' > associate_contents[_pass = complainContents])
77  ^ (',' > associate_sdds[_pass = complainSDDS]));
79  ((associate_name[_pass = complainName] > ',')
80  ^ (associate_filename[_pass = complainFilename] > ',')
81  ^ (associate_path[_pass = complainPath] > ',')
82  ^ (associate_description[_pass = complainDescription] > ',')
83  ^ (associate_contents[_pass = complainContents] > ',')
84  ^ (associate_sdds[_pass = complainSDDS] > ','));
85 
86  start =
87  lit("&associate")[_pass = complainAssociate]
88  > lit("&end");
89 
90  BOOST_SPIRIT_DEBUG_NODES(
91  (start)
92  )
93 
94  on_error<fail>(start,
95  error_handler_function(_error_handler)(
96  std::string("Error! Expecting "), _4, _3));
97  }
98 }}
99 #endif /* ASSOCIATE_HPP_ */
constexpr double alpha
The fine structure constant, no dimension.
Definition: Physics.h:78
Definition: array.hpp:33
associate_parser(error_handler< Iterator > &_error_handler)
qi::rule< Iterator, ast::nil(), skipper< Iterator > > associate_unsupported_pre
Definition: associate.hpp:110
qi::rule< Iterator, ast::nil(), skipper< Iterator > > associate_unsupported_post
Definition: associate.hpp:111
qi::rule< Iterator, std::string(), skipper< Iterator > > associate_contents
Definition: associate.hpp:108
qi::rule< Iterator, std::string(), skipper< Iterator > > string
Definition: associate.hpp:106
qi::rule< Iterator, associate(), skipper< Iterator > > start
Definition: associate.hpp:105
qi::rule< Iterator, std::string(), skipper< Iterator > > associate_filename
Definition: associate.hpp:107
qi::rule< Iterator, std::string(), skipper< Iterator > > quoted_string
Definition: associate.hpp:106
qi::rule< Iterator, long(), skipper< Iterator > > associate_sdds
Definition: associate.hpp:109
qi::rule< Iterator, std::string(), skipper< Iterator > > associate_description
Definition: associate.hpp:107
qi::rule< Iterator, std::string(), skipper< Iterator > > associate_path
Definition: associate.hpp:107
qi::rule< Iterator, std::string(), skipper< Iterator > > associate_name
Definition: associate.hpp:107