mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
ircd::spirit: Add template id to custom_parser; add three specializations per unit for now.
This commit is contained in:
parent
a73b538349
commit
30e5a0110c
2 changed files with 58 additions and 13 deletions
|
@ -16,8 +16,11 @@ namespace spirit
|
|||
__attribute__((visibility("internal")))
|
||||
{
|
||||
struct substring_view;
|
||||
struct custom_parser;
|
||||
BOOST_SPIRIT_TERMINAL(custom);
|
||||
|
||||
template<size_t id> struct custom_parser;
|
||||
BOOST_SPIRIT_TERMINAL(custom0);
|
||||
BOOST_SPIRIT_TERMINAL(custom1);
|
||||
BOOST_SPIRIT_TERMINAL(custom2);
|
||||
|
||||
template<class gen,
|
||||
class... attr>
|
||||
|
@ -37,18 +40,35 @@ __attribute__((visibility("internal")))
|
|||
namespace qi
|
||||
{
|
||||
template<class modifiers>
|
||||
struct make_primitive<ircd::spirit::tag::custom, modifiers>;
|
||||
struct make_primitive<ircd::spirit::tag::custom0, modifiers>;
|
||||
|
||||
template<class modifiers>
|
||||
struct make_primitive<ircd::spirit::tag::custom1, modifiers>;
|
||||
|
||||
template<class modifiers>
|
||||
struct make_primitive<ircd::spirit::tag::custom2, modifiers>;
|
||||
}
|
||||
|
||||
template<>
|
||||
struct use_terminal<qi::domain, ircd::spirit::tag::custom>
|
||||
struct use_terminal<qi::domain, ircd::spirit::tag::custom0>
|
||||
:mpl::true_
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct use_terminal<qi::domain, ircd::spirit::tag::custom1>
|
||||
:mpl::true_
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct use_terminal<qi::domain, ircd::spirit::tag::custom2>
|
||||
:mpl::true_
|
||||
{};
|
||||
}}
|
||||
|
||||
template<size_t id>
|
||||
struct [[gnu::visibility("internal")]]
|
||||
ircd::spirit::custom_parser
|
||||
:qi::primitive_parser<custom_parser>
|
||||
:qi::primitive_parser<custom_parser<id>>
|
||||
{
|
||||
template<class context,
|
||||
class iterator>
|
||||
|
@ -72,9 +92,33 @@ ircd::spirit::custom_parser
|
|||
|
||||
template<class modifiers>
|
||||
struct [[gnu::visibility("internal")]]
|
||||
boost::spirit::qi::make_primitive<ircd::spirit::tag::custom, modifiers>
|
||||
boost::spirit::qi::make_primitive<ircd::spirit::tag::custom0, modifiers>
|
||||
{
|
||||
using result_type = ircd::spirit::custom_parser;
|
||||
using result_type = ircd::spirit::custom_parser<0>;
|
||||
|
||||
result_type operator()(unused_type, unused_type) const
|
||||
{
|
||||
return result_type{};
|
||||
}
|
||||
};
|
||||
|
||||
template<class modifiers>
|
||||
struct [[gnu::visibility("internal")]]
|
||||
boost::spirit::qi::make_primitive<ircd::spirit::tag::custom1, modifiers>
|
||||
{
|
||||
using result_type = ircd::spirit::custom_parser<1>;
|
||||
|
||||
result_type operator()(unused_type, unused_type) const
|
||||
{
|
||||
return result_type{};
|
||||
}
|
||||
};
|
||||
|
||||
template<class modifiers>
|
||||
struct [[gnu::visibility("internal")]]
|
||||
boost::spirit::qi::make_primitive<ircd::spirit::tag::custom2, modifiers>
|
||||
{
|
||||
using result_type = ircd::spirit::custom_parser<2>;
|
||||
|
||||
result_type operator()(unused_type, unused_type) const
|
||||
{
|
||||
|
|
13
ircd/json.cc
13
ircd/json.cc
|
@ -164,7 +164,7 @@ ircd::json::parser
|
|||
};
|
||||
|
||||
template<class block_t> static u64x2 string_content_block(const block_t, const block_t) noexcept;
|
||||
const custom_parser string_content{};
|
||||
const custom_parser<0> string_content{};
|
||||
const rule<string_view> string
|
||||
{
|
||||
//quote >> chars >> (!escape >> quote)
|
||||
|
@ -474,16 +474,17 @@ const
|
|||
/// to the end of whatever the user provided. Returns true if successful and
|
||||
/// the result string_view is set in the context attribute; the iterator is
|
||||
/// advanced.
|
||||
template<>
|
||||
template<class iterator,
|
||||
class context,
|
||||
class skipper,
|
||||
class attr>
|
||||
inline bool
|
||||
ircd::json::custom_parser::parse(iterator &__restrict__ start,
|
||||
const iterator &__restrict__ stop,
|
||||
context &g,
|
||||
const skipper &,
|
||||
attr &)
|
||||
ircd::json::custom_parser<0>::parse(iterator &__restrict__ start,
|
||||
const iterator &__restrict__ stop,
|
||||
context &g,
|
||||
const skipper &,
|
||||
attr &)
|
||||
const
|
||||
{
|
||||
// Clang scales between 128bit and 256bit systems when we use the 256 bit
|
||||
|
|
Loading…
Reference in a new issue