1 #ifndef fhiclcpp_tokens_h 2 #define fhiclcpp_tokens_h 10 #include "boost/spirit/home/support/terminal.hpp" 11 #include "boost/spirit/include/qi.hpp" 30 return !std::isgraph(ch) || ch ==
'#' || ch ==
'/' || ch ==
',' ||
31 ch ==
']' || ch ==
'}';
58 BOOST_SPIRIT_TERMINAL(real)
59 BOOST_SPIRIT_TERMINAL(
uint)
60 BOOST_SPIRIT_TERMINAL(
hex)
61 BOOST_SPIRIT_TERMINAL(
bin)
62 BOOST_SPIRIT_TERMINAL(ass)
63 BOOST_SPIRIT_TERMINAL(dss)
64 BOOST_SPIRIT_TERMINAL(dbid)
65 BOOST_SPIRIT_TERMINAL(binding)
75 struct use_terminal<
qi::domain, fhicl::tag::real> : mpl::true_ {};
84 struct use_terminal<qi::domain, fhicl::tag::dbid> : mpl::true_ {};
90 struct use_terminal<qi::domain, fhicl::tag::ass> : mpl::true_ {};
93 struct use_terminal<qi::domain, fhicl::tag::dss> : mpl::true_ {};
96 struct use_terminal<qi::domain, fhicl::tag::binding> : mpl::true_ {};
107 template <
typename Context,
typename Iterator>
113 template <
typename Iterator,
119 Iterator
const& last,
121 Skipper
const& skipper,
122 Attribute& attr)
const 124 boost::spirit::qi::skip_over(first, last, skipper);
126 static std::string const allowed{
"0123456789.-+eE"};
128 while (it != last && allowed.find(*it) != std::string::npos)
134 Attribute
raw(first, it);
143 boost::spirit::traits::assign_to(result, attr);
148 template <
typename Context>
157 struct uint_parser : boost::spirit::qi::primitive_parser<uint_parser> {
159 template <
typename Context,
typename Iterator>
165 template <
typename Iterator,
171 Iterator
const& last,
173 Skipper
const& skipper,
174 Attribute& attr)
const 176 boost::spirit::qi::skip_over(first, last, skipper);
179 while (it != last && std::isdigit(*it))
181 Attribute
result(first, it);
189 for (std::size_t ndig = result.size(); ndig > 1 && result[0] ==
'0';
194 boost::spirit::traits::assign_to(result, attr);
199 template <
typename Context>
210 template <
typename Context,
typename Iterator>
216 template <
typename Iterator,
222 Iterator
const& last,
224 Skipper
const& skipper,
225 Attribute& attr)
const 227 boost::spirit::qi::skip_over(first, last, skipper);
229 static std::string const allowed{
"0123456789abcdefABCDEF"};
232 if (it == last || *it !=
'0')
237 if (it == last || toupper(*it) !=
'X')
242 while (it != last && allowed.find(*it) != std::string::npos)
248 Attribute
raw(first, it);
249 if (raw.empty() || raw.size() == 2)
257 boost::spirit::traits::assign_to(result, attr);
262 template <
typename Context>
273 template <
typename Context,
typename Iterator>
279 template <
typename Iterator,
285 Iterator
const& last,
287 Skipper
const& skipper,
288 Attribute& attr)
const 290 boost::spirit::qi::skip_over(first, last, skipper);
292 static std::string const allowed{
"0123456789abcdefABCDEF"};
298 while (it != last && allowed.find(*it) != std::string::npos)
304 Attribute
result(first, it);
309 boost::spirit::traits::assign_to(result, attr);
314 template <
typename Context>
325 template <
typename Context,
typename Iterator>
331 template <
typename Iterator,
337 Iterator
const& last,
339 Skipper
const& skipper,
340 Attribute& attr)
const 342 boost::spirit::qi::skip_over(first, last, skipper);
347 if (it == last || *it !=
'0')
352 if (it == last || toupper(*it) !=
'B')
357 while (it != last && allowed.find(*it) != std::string::npos)
363 Attribute
raw(first, it);
364 if (raw.empty() || raw.size() == 2)
372 boost::spirit::traits::assign_to(result, attr);
377 template <
typename Context>
388 template <
typename Context,
typename Iterator>
394 template <
typename Iterator,
400 Iterator
const& last,
402 Skipper
const& skipper,
403 Attribute& attr)
const 405 boost::spirit::qi::skip_over(first, last, skipper);
408 while (it != last && (std::isalnum(*it) || *it ==
'_'))
414 Attribute
result(first, it);
415 if (result.empty() || std::isdigit(result[0]))
419 boost::spirit::traits::assign_to(result, attr);
424 template <
typename Context>
435 template <
typename Context,
typename Iterator>
441 template <
typename Iterator,
447 Iterator
const& last,
449 Skipper
const& skipper,
450 Attribute& attr)
const 452 boost::spirit::qi::skip_over(first, last, skipper);
454 bool all_digits =
true;
456 for (; it != last && (std::isalnum(*it) || *it ==
'_'); ++it)
457 all_digits = all_digits && std::isdigit(*it);
462 Attribute
result(first, it);
463 if (result.empty() || all_digits || !std::isdigit(result[0]))
467 boost::spirit::traits::assign_to(result, attr);
472 template <
typename Context>
483 template <
typename Context,
typename Iterator>
489 template <
typename Iterator,
495 Iterator
const& last,
497 Skipper
const& skipper,
498 Attribute& attr)
const 501 boost::spirit::qi::skip_over(first, last, skipper);
504 boost::spirit::qi::symbols<char, binding_modifier>
modifiers;
509 modifiers.add(
"@replace", binding_modifier::REPLACE);
510 modifiers.add(
"@replace_compat", binding_modifier::REPLACE_COMPAT);
511 modifiers.add(
"@add_or_replace_compat", binding_modifier::ADD_OR_REPLACE_COMPAT);
513 if (((*first) ==
':') ||
514 (modifiers.parse(first, last, c, skipper, result) &&
520 boost::spirit::traits::assign_to(result, attr);
525 template <
typename Context>
542 template <
typename Modifiers>
543 struct make_primitive<
fhicl::tag::real, Modifiers> {
553 template <
typename Modifiers>
564 template <
typename Modifiers>
575 template <
typename Modifiers>
576 struct make_primitive<
fhicl::tag::dbid, Modifiers> {
586 template <
typename Modifiers>
597 template <
typename Modifiers>
598 struct make_primitive<
fhicl::tag::ass, Modifiers> {
608 template <
typename Modifiers>
609 struct make_primitive<
fhicl::tag::dss, Modifiers> {
619 template <
typename Modifiers>
620 struct make_primitive<
fhicl::tag::binding, Modifiers> {
result_type operator()(unused_type, unused_type) const
static QMap< Entry *, QMap< QCString, SymbolModifiers > > modifiers
Holds program scope->symbol name->symbol modifiers.
bool parse(Iterator &first, Iterator const &last, Context &c, Skipper const &skipper, Attribute &attr) const
bool canonical_number(std::string const &value, std::string &result)
result_type operator()(unused_type, unused_type) const
QTextStream & hex(QTextStream &s)
bool maximally_munched(char const ch)
bool parse(Iterator &first, Iterator const &last, Context &, Skipper const &skipper, Attribute &attr) const
boost::spirit::info what(Context &) const
boost::spirit::info what(Context &) const
bool parse(Iterator &first, Iterator const &last, Context &, Skipper const &skipper, Attribute &attr) const
result_type operator()(unused_type, unused_type) const
static constexpr std::size_t max_str_size() noexcept
bool maximally_munched_dss(char const ch)
bool parse(Iterator &first, Iterator const &last, Context &, Skipper const &skipper, Attribute &attr) const
bool parse(Iterator &first, Iterator const &last, Context &, Skipper const &skipper, Attribute &attr) const
boost::spirit::info what(Context &) const
bool parse(Iterator &first, Iterator const &last, Context &, Skipper const &skipper, Attribute &attr) const
result_type operator()(unused_type, unused_type) const
boost::spirit::info what(Context &) const
boost::spirit::info what(Context &) const
QTextStream & bin(QTextStream &s)
result_type operator()(unused_type, unused_type) const
boost::spirit::info what(Context &) const
bool parse(Iterator &first, Iterator const &last, Context &, Skipper const &skipper, Attribute &attr) const
bool maximally_munched_number(char const ch)
bool parse(Iterator &first, Iterator const &last, Context &, Skipper const &skipper, Attribute &attr) const
result_type operator()(unused_type, unused_type) const
result_type operator()(unused_type, unused_type) const
boost::spirit::info what(Context &) const
boost::spirit::info what(Context &) const
bool maximally_munched_ass(char const ch)
result_type operator()(unused_type, unused_type) const