9 #ifndef PARAMETER_DEF_HPP_
10 #define PARAMETER_DEF_HPP_
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_object.hpp>
18 #include <boost/spirit/include/phoenix_bind.hpp>
20 namespace SDDS {
namespace parser
22 template <
typename Iterator>
23 parameter_parser<Iterator>::parameter_parser(error_handler<Iterator> & _error_handler):
24 parameter_parser::base_type(start)
30 typedef function<error_handler<Iterator> > error_handler_function;
36 qi::lexeme_type lexeme;
46 quoted_string %= lexeme[
'"' >> +(char_ -
'"') >>
'"'];
47 string %= quoted_string
48 | lexeme[(alpha | char_(
"@:#+-%._$&/")) >> *(alnum | char_(
"@:#+-%._$&/"))];
49 units %= lexeme[alpha >> *(alpha | char_(
'/'))]
61 parameter_name = lit(
"name") >
'=' > string;
62 parameter_units %= lit(
"units") >
'=' > units;
63 parameter_description %= lit(
"description") >
'=' > string;
64 parameter_type %= lit(
"type") >
'=' >
datatype;
65 parameter_symbol = lit(
"symbol") >
'=' > string;
66 parameter_format = lit(
"format_string") >
'=' > string;
67 parameter_fixed = lit(
"fixed_value") > long_;
69 auto complainSymbol = phx::bind(¶meter::complainUnsupported<parameter::SYMBOL>::apply);
70 auto complainFormat = phx::bind(¶meter::complainUnsupported<parameter::FORMAT_STRING>::apply);
71 auto complainFixed = phx::bind(¶meter::complainUnsupported<parameter::FIXED_VALUE>::apply);
73 parameter_unsupported_pre =
74 ((
',' > parameter_symbol[_pass = complainSymbol])
75 ^ (
',' > parameter_format[_pass = complainFormat])
76 ^ (
',' > parameter_fixed[_pass = complainFixed])
78 parameter_unsupported_post =
79 ((parameter_symbol[_pass = complainSymbol] >
',')
80 ^ (parameter_format[_pass = complainFormat] >
',')
81 ^ (parameter_fixed[_pass = complainFixed] >
',')
86 > -parameter_unsupported_post
87 >> ((parameter_name[phx::at_c<0>(_val) = _1]
88 >> ((
',' >> parameter_type[phx::at_c<1>(_val) = _1])
89 ^(
',' >> parameter_units[phx::at_c<2>(_val) = _1])
90 ^(
',' >> parameter_description[phx::at_c<3>(_val) = _1])
92 |(parameter_type[phx::at_c<1>(_val) = _1]
93 >> ((
',' >> parameter_name[phx::at_c<0>(_val) = _1])
94 ^(
',' >> parameter_units[phx::at_c<2>(_val) = _1])
95 ^(
',' >> parameter_description[phx::at_c<3>(_val) = _1])
97 |(parameter_units[phx::at_c<2>(_val) = _1]
98 >> ((
',' >> parameter_type[phx::at_c<1>(_val) = _1])
99 ^(
',' >> parameter_name[phx::at_c<0>(_val) = _1])
100 ^(
',' >> parameter_description[phx::at_c<3>(_val) = _1])
102 |(parameter_description[phx::at_c<3>(_val) = _1]
103 >> ((
',' >> parameter_type[phx::at_c<1>(_val) = _1])
104 ^(
',' >> parameter_units[phx::at_c<2>(_val) = _1])
105 ^(
',' >> parameter_name[phx::at_c<0>(_val) = _1])
108 > -parameter_unsupported_pre
110 >> eps[_pass = phx::bind(¶meter::checkMandatories, _val)];
112 BOOST_SPIRIT_DEBUG_NODES(
116 on_error<fail>(start,
117 error_handler_function(_error_handler)(
118 std::
string("Error! Expecting "), _4, _3));
constexpr double alpha
The fine structure constant, no dimension.