27 #include <boost/spirit/include/qi.hpp>
28 #include <boost/spirit/include/phoenix.hpp>
29 #include <boost/fusion/include/std_pair.hpp>
50 template<
typename ITERT>
51 struct id_parser : boost::spirit::qi::grammar<ITERT,pni::core::string()>
54 boost::spirit::qi::rule<ITERT,pni::core::string()>
id_rule;
63 id_rule = +qi::char_(
"-_a-zA-Z0-9");
74 template<
typename ITERT>
75 struct dot_parser : boost::spirit::qi::grammar<ITERT,pni::core::string()>
77 boost::spirit::qi::rule<ITERT,pni::core::string()>
dot_rule;
84 dot_rule = lit(
".")[_val =
"."]||lit(
".")[_val +=
"."];
100 template<
typename ITERT>
106 boost::spirit::locals<
110 nxpath::element_type()
116 typedef boost::spirit::qi::rule<ITERT,pni::core::string()>
119 typedef boost::spirit::locals<pni::core::string,pni::core::string>
129 boost::spirit::qi::rule< ITERT,locals_type,nxpath::element_type()>
140 name_rule = id_[_val = _1] | dots_[_val=_1];
142 class_rule = lit(
":") > id_[_val = _1];
144 element_rule = eps[_a =
"", _b=
""]>>(
145 name_rule[_a = _1] || class_rule[_b = _1]
146 )[_val = construct<element_type>(_a,_b)];
163 template<
typename ITERT>
179 elements_rule = (element_ %
'/') >-lit(
"/");
196 template<
typename ITERT>
198 boost::spirit::locals
200 nxpath::elements_type,
206 boost::spirit::qi::rule<ITERT,
207 boost::spirit::locals
215 boost::spirit::qi::rule<ITERT,nxpath::element_type()>
root_rule;
235 using boost::spirit::qi::_1;
237 using boost::phoenix::ref;
239 root_rule = lit(
"/")[_val = construct<nxpath::element_type>(
"/",
"NXroot")];
240 root_rule.name(
"root_rule");
242 #pragma clang diagnostic push
243 #pragma clang diagnostic ignored "-Wunsequenced"
247 _a = construct<nxpath::elements_type>(),
252 _val = construct<nxpath>(boost::phoenix::ref(_filename),_a,_b),
254 push_back(_val,construct<nxpath::element_type>(
"/",
"NXroot"))
258 root_rule[push_back(_a,_1)]
263 (lit(
"@")>id_[_b=_1])
264 ) [_val = construct<nxpath>(boost::phoenix::ref(_filename),_a,_b)]
267 #pragma clang diagnostic pop
nxpath_parser(const pni::core::string &fname="")
constructor
Definition: nx/nxpath/parser.hpp:229
parser dots
Definition: nx/nxpath/parser.hpp:75
boost::spirit::qi::rule< ITERT, pni::core::string()> string_rule_type
string rule type
Definition: nx/nxpath/parser.hpp:117
std::list< element_type > elements_type
a list of subsequent objects
Definition: nxpath/nxpath.hpp:66
boost::phoenix::function< stl::insert > const insert
Definition: insert.hpp:101
Definition: spirit_container_traits.hpp:33
nxpath parse_path(const pni::core::string &input)
parser string to path
Definition: parser.cpp:38
parser for group elements
Definition: nx/nxpath/parser.hpp:104
boost::spirit::locals< pni::core::string, pni::core::string > locals_type
type for parser locals
Definition: nx/nxpath/parser.hpp:120
string_rule_type class_rule
rule for a class
Definition: nx/nxpath/parser.hpp:123
string_rule_type name_rule
rule for a single name
Definition: nx/nxpath/parser.hpp:122
element_parser< ITERT > element_
group element parser
Definition: nx/nxpath/parser.hpp:171
id_parser()
default constructor
Definition: nx/nxpath/parser.hpp:59
pni::core::string _filename
the filename part
Definition: nx/nxpath/parser.hpp:273
id_parser< ITERT > id_
rule for a path ID
Definition: nx/nxpath/parser.hpp:125
Definition: cbf_reader.hpp:41
boost::spirit::qi::rule< ITERT, pni::core::string()> id_rule
the major rule to parse an ID
Definition: nx/nxpath/parser.hpp:54
auto begin(const OTYPE< IMPID > &group) -> decltype(group.begin())
get iterator to first element
Definition: iterators.hpp:46
elements_parser< ITERT > element_rule
parser for a single element
Definition: nx/nxpath/parser.hpp:221
std::pair< pni::core::string, pni::core::string > element_type
object element (groupname:class)
Definition: nxpath/nxpath.hpp:64
dot_parser()
Definition: nx/nxpath/parser.hpp:79
id_parser< ITERT > id_
parser for an individual Nexus ID
Definition: nx/nxpath/parser.hpp:218
parser for a nexus path
Definition: nx/nxpath/parser.hpp:197
auto end(const OTYPE< IMPID > &group) -> decltype(group.end())
get iterator to last element
Definition: iterators.hpp:69
nexus identifier parser
Definition: nx/nxpath/parser.hpp:51
parser for group path
Definition: nx/nxpath/parser.hpp:166
boost::spirit::qi::rule< ITERT, boost::spirit::locals< nxpath::elements_type, pni::core::string >, nxpath()> nxpath_rule
rule for the path
Definition: nx/nxpath/parser.hpp:212
boost::spirit::qi::rule< ITERT, locals_type, nxpath::element_type()> element_rule
rule for a full group element
Definition: nx/nxpath/parser.hpp:130
boost::spirit::qi::rule< ITERT, nxpath::elements_type()> elements_rule
rule for the entire group portion
Definition: nx/nxpath/parser.hpp:169
boost::spirit::qi::rule< ITERT, pni::core::string()> dot_rule
Definition: nx/nxpath/parser.hpp:77
Nexus path class.
Definition: nxpath/nxpath.hpp:60
dot_parser< ITERT > dots_
rule to parse dots
Definition: nx/nxpath/parser.hpp:126
boost::spirit::qi::rule< ITERT, nxpath::element_type()> root_rule
rule for the root part of the path
Definition: nx/nxpath/parser.hpp:215
element_parser()
default constructor
Definition: nx/nxpath/parser.hpp:133
elements_parser()
default constructor
Definition: nx/nxpath/parser.hpp:174
nxpath::element_type element_type
a single path element type
Definition: nx/nxpath/parser.hpp:114