9 #ifndef COLUMN_DEF_HPP_
10 #define COLUMN_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 column_parser<Iterator>::column_parser(error_handler<Iterator> & _error_handler):
24 column_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 %= char_(
'1') | lexeme[alpha >> *(alpha | char_(
'/'))];
60 column_name = lit(
"name") >
'=' > string;
61 column_units %= lit(
"units") >
'=' > units;
62 column_description %= lit(
"description") >
'=' > string;
63 column_type %= lit(
"type") >
'=' >
datatype;
64 column_symbol = lit(
"symbol") >
'=' > string;
65 column_format = lit(
"format_string") >
'=' > string;
66 column_field = lit(
"field_length") >
'=' > long_;
68 auto complainSymbol = phx::bind(&column::complainUnsupported<column::SYMBOL>::apply);
69 auto complainFormat = phx::bind(&column::complainUnsupported<column::FORMAT_STRING>::apply);
70 auto complainField = phx::bind(&column::complainUnsupported<column::FIELD_LENGTH>::apply);
72 column_unsupported_pre =
73 ((
',' > column_symbol[_pass = complainSymbol])
74 ^ (
',' > column_format[_pass = complainFormat])
75 ^ (
',' > column_field[_pass = complainField])
77 column_unsupported_post =
78 ((column_symbol[_pass = complainSymbol] >
',')
79 ^ (column_format[_pass = complainFormat] >
',')
80 ^ (column_field[_pass = complainField] >
',')
85 > -column_unsupported_post
86 >> ((column_name[phx::at_c<0>(_val) = _1]
87 >> ((
',' >> column_type[phx::at_c<1>(_val) = _1])
88 ^(
',' >> column_units[phx::at_c<2>(_val) = _1])
89 ^(
',' >> column_description[phx::at_c<3>(_val) = _1])
91 |(column_type[phx::at_c<1>(_val) = _1]
92 >> ((
',' >> column_name[phx::at_c<0>(_val) = _1])
93 ^(
',' >> column_units[phx::at_c<2>(_val) = _1])
94 ^(
',' >> column_description[phx::at_c<3>(_val) = _1])
96 |(column_units[phx::at_c<2>(_val) = _1]
97 >> ((
',' >> column_type[phx::at_c<1>(_val) = _1])
98 ^(
',' >> column_name[phx::at_c<0>(_val) = _1])
99 ^(
',' >> column_description[phx::at_c<3>(_val) = _1])
101 |(column_description[phx::at_c<3>(_val) = _1]
102 >> ((
',' >> column_type[phx::at_c<1>(_val) = _1])
103 ^(
',' >> column_units[phx::at_c<2>(_val) = _1])
104 ^(
',' >> column_name[phx::at_c<0>(_val) = _1])
107 > -column_unsupported_pre
109 >> eps[_pass = phx::bind(&column::checkMandatories, _val)];
111 BOOST_SPIRIT_DEBUG_NODES(
115 on_error<fail>(start,
116 error_handler_function(_error_handler)(
117 std::
string("Error! Expecting "), _4, _3));
constexpr double alpha
The fine structure constant, no dimension.