17 #ifndef COLUMN_DEF_HPP_
18 #define COLUMN_DEF_HPP_
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_object.hpp>
26 #include <boost/spirit/include/phoenix_bind.hpp>
28 namespace SDDS {
namespace parser
30 template <
typename Iterator>
31 column_parser<Iterator>::column_parser(error_handler<Iterator> & _error_handler):
32 column_parser::base_type(start)
38 typedef function<error_handler<Iterator> > error_handler_function;
44 qi::lexeme_type lexeme;
54 quoted_string %= lexeme[
'"' >> +(char_ -
'"') >>
'"'];
55 string %= quoted_string
56 | lexeme[(
alpha | char_(
"@:#+-%._$&/")) >> *(alnum | char_(
"@:#+-%._$&/"))];
57 units %= char_(
'1') | lexeme[
alpha >> *(
alpha | char_(
'/'))];
68 column_name = lit(
"name") >
'=' > string;
69 column_units %= lit(
"units") >
'=' > units;
70 column_description %= lit(
"description") >
'=' > string;
71 column_type %= lit(
"type") >
'=' >
datatype;
72 column_symbol = lit(
"symbol") >
'=' > string;
73 column_format = lit(
"format_string") >
'=' > string;
74 column_field = lit(
"field_length") >
'=' > long_;
76 auto complainSymbol = phx::bind(&column::complainUnsupported<column::SYMBOL>::apply);
77 auto complainFormat = phx::bind(&column::complainUnsupported<column::FORMAT_STRING>::apply);
78 auto complainField = phx::bind(&column::complainUnsupported<column::FIELD_LENGTH>::apply);
80 column_unsupported_pre =
81 ((
',' > column_symbol[_pass = complainSymbol])
82 ^ (
',' > column_format[_pass = complainFormat])
83 ^ (
',' > column_field[_pass = complainField])
85 column_unsupported_post =
86 ((column_symbol[_pass = complainSymbol] >
',')
87 ^ (column_format[_pass = complainFormat] >
',')
88 ^ (column_field[_pass = complainField] >
',')
93 > -column_unsupported_post
94 >> ((column_name[phx::at_c<0>(_val) = _1]
95 >> ((
',' >> column_type[phx::at_c<1>(_val) = _1])
96 ^(
',' >> column_units[phx::at_c<2>(_val) = _1])
97 ^(
',' >> column_description[phx::at_c<3>(_val) = _1])
99 |(column_type[phx::at_c<1>(_val) = _1]
100 >> ((
',' >> column_name[phx::at_c<0>(_val) = _1])
101 ^(
',' >> column_units[phx::at_c<2>(_val) = _1])
102 ^(
',' >> column_description[phx::at_c<3>(_val) = _1])
104 |(column_units[phx::at_c<2>(_val) = _1]
105 >> ((
',' >> column_type[phx::at_c<1>(_val) = _1])
106 ^(
',' >> column_name[phx::at_c<0>(_val) = _1])
107 ^(
',' >> column_description[phx::at_c<3>(_val) = _1])
109 |(column_description[phx::at_c<3>(_val) = _1]
110 >> ((
',' >> column_type[phx::at_c<1>(_val) = _1])
111 ^(
',' >> column_units[phx::at_c<2>(_val) = _1])
112 ^(
',' >> column_name[phx::at_c<0>(_val) = _1])
115 > -column_unsupported_pre
117 >> eps[_pass = phx::bind(&column::checkMandatories, _val)];
119 BOOST_SPIRIT_DEBUG_NODES(
123 on_error<fail>(start,
124 error_handler_function(_error_handler)(
125 std::string(
"Error! Expecting "), _4, _3));
constexpr double alpha
The fine structure constant, no dimension.