Go to the documentation of this file.
11 #ifndef JOBOPTIONSVC_GRAMMAR_H_
12 #define JOBOPTIONSVC_GRAMMAR_H_
24 #include <boost/phoenix/core.hpp>
25 #include <boost/phoenix/fusion.hpp>
26 #include <boost/phoenix/operator.hpp>
27 #include <boost/phoenix/stl.hpp>
28 #include <boost/spirit/include/qi.hpp>
29 #include <boost/spirit/repository/include/qi_confix.hpp>
30 #include <boost/spirit/repository/include/qi_iter_pos.hpp>
42 namespace sp = boost::spirit;
43 namespace ph = boost::phoenix;
44 namespace qi = sp::qi;
45 namespace enc = sp::ascii;
46 namespace rep = sp::repository;
50 template <
typename Iterator>
53 comments = enc::space | rep::confix(
"/*",
"*/" )[*( qi::char_ -
"*/" )] |
54 rep::confix(
"//", ( sp::eol | sp::eoi ) )[*( qi::char_ - ( sp::eol | sp::eoi ) )];
59 template <
typename Iterator,
typename Skipper>
60 struct StringGrammar : qi::grammar<Iterator, std::string(), qi::locals<char>, Skipper> {
66 quote = enc::char_( qi::_r1 );
69 *( ( enc::char_(
'\\' ) >>
quote( qi::_a ) )[qi::_val += qi::_a] |
70 ( enc::char_[qi::_val += qi::_1] -
quote( qi::_a ) ) ) >>
80 template <
typename Iterator,
typename Skipper>
88 str = -qi::lit(
"::" )[qi::_val +=
"::"] >>
inner[qi::_val += qi::_1] >>
89 *( qi::lit(
"::" ) >>
inner[qi::_val += (
"::" + qi::_1 )] );
90 inner = qi::alpha >> *( qi::alnum | qi::char_(
'_' ) );
96 ph::function<NodeOperations>
op;
99 template <
typename Iterator,
typename Skipper>
105 boolean = enc::no_case[qi::lit(
"true" )[qi::_val =
true] | qi::lit(
"false" )[qi::_val =
false]];
111 template <
typename Iterator,
typename Skipper>
117 real = qi::raw[qi::double_][
op( qi::_val, qi::_1 )][
op( qi::_val,
Node::kReal )] >> -qi::char_(
'L' ) >>
118 -( -qi::char_(
'*' ) >>
gunit[
op( qi::_val, qi::_1 )] );
123 ph::function<NodeOperations>
op;
126 template <
typename Iterator,
typename Skipper>
131 unit = rep::qi::iter_pos[
op( qi::_val, qi::_1 )] >>
val[
op( qi::_val, qi::_1 )] >> -qi::lit(
'*' ) >>
132 gunit[
op( qi::_val, qi::_1 )] >> qi::lit(
'=' ) >>
140 ph::function<NodeOperations>
op;
143 template <
typename Iterator,
typename Skipper>
149 qi::eol )[*( qi::char_[qi::_a += qi::_1] - qi::eol )][
op( qi::_val,
Node::kShell )][
op( qi::_val, qi::_a )];
151 condition )[qi::_val = qi::_1][
op( qi::_val, qi::_a )];
156 *
statement[
op( qi::_b, qi::_1 )] )[
op( qi::_val, qi::_b )] >>
167 value[
op( qi::_val, qi::_1 )] >>
';';
168 property = rep::qi::iter_pos[
op( qi::_val, qi::_1 )] >>
171 oper = rep::qi::iter_pos[
op( qi::_val, qi::_1 )] >>
177 enc::char_(
'(' )[qi::_val =
')'] | enc::char_(
'[' )[qi::_val =
']'] | enc::char_(
'{' )[qi::_val =
'}'];
181 map_value = ( enc::char_(
'{' ) >> -(
pair[
op( qi::_val, qi::_1 )] %
',' ) >>
188 qi::rule<
Iterator,
Node(),
Skipper>
file,
include,
assign,
property,
property_ref,
oper,
map_value,
pair_value,
200 ph::function<NodeOperations>
op;
206 #endif // JOBOPTIONSVC_GRAMMAR_H_
qi::rule< Iterator, Node(), Skipper > val
qi::rule< Iterator, Node(), Skipper > units
qi::rule< Iterator, char()> begin_quote
IdentifierGrammar< Iterator, Skipper > gunit
qi::rule< Iterator, Node(), Skipper > oper
qi::rule< Iterator, Node(), Skipper > file
qi::rule< Iterator, Node(), Skipper > simple_value
qi::rule< Iterator, void(char)> end_vector
IdentifierGrammar< Iterator, Skipper > gidentifier
qi::rule< Iterator, Node(), Skipper > pair
qi::rule< Iterator, std::string()> inner
RealGrammar< Iterator, Skipper > greal
qi::rule< Iterator, Node(), Skipper > property_ref
qi::rule< Iterator, Node(), Skipper > pragma_dump_file
qi::rule< Iterator, Node(), qi::locals< Iterator >, Skipper > statement
ph::function< NodeOperations > op
qi::rule< Iterator, Node(), Skipper > assign
qi::rule< Iterator, Node(), Skipper > pragma_tree
qi::rule< Iterator, Node(), Skipper > real
qi::rule< Iterator, Node(), Skipper > map_value
qi::rule< Iterator, Node(), qi::locals< Node, Node >, Skipper > condition
qi::rule< Iterator, Node(), qi::locals< char >, Skipper > vector_value
qi::rule< Iterator, void(char)> quote
qi::rule< Iterator, char()> begin_vector
ph::function< NodeOperations > op
qi::rule< Iterator > comments
qi::rule< Iterator, Node(), Skipper > units
qi::rule< Iterator, Node(), Skipper > property
qi::rule< Iterator, Node(), Skipper > include
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
IdentifierGrammar< Iterator, Skipper > gunit
qi::rule< Iterator, bool(), Skipper > boolean
ph::function< NodeOperations > op
qi::rule< Iterator, Node(), Skipper > unit
qi::rule< Iterator, std::string(), Skipper > str
qi::rule< Iterator, Node(), Skipper > print_options
StringGrammar< Iterator, Skipper > gstring
ph::function< NodeOperations > op
qi::rule< Iterator, Node(), Skipper > pragma_print
qi::rule< Iterator, Node(), Skipper > pair_value
BoolGrammar< Iterator, Skipper > gbool
qi::rule< Iterator, Node(), Skipper > ident
qi::rule< Iterator, Node(), Skipper > pragma
qi::rule< Iterator, Node(), qi::locals< std::string > > shell
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
qi::rule< Iterator, std::string(), qi::locals< char >, Skipper > str
qi::rule< Iterator, Node(), qi::locals< Iterator >, Skipper > value