0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd: Consolidate spirit typedefs from all relevant units into spirit.h.

This commit is contained in:
Jason Volk 2018-03-17 10:44:40 -07:00
parent d81291e367
commit 30eb9178bd
7 changed files with 60 additions and 135 deletions

View file

@ -21,3 +21,41 @@
#include <boost/fusion/include/std_pair.hpp> #include <boost/fusion/include/std_pair.hpp>
#include <boost/fusion/adapted/std_pair.hpp> #include <boost/fusion/adapted/std_pair.hpp>
#include <boost/fusion/adapted/std_tuple.hpp> #include <boost/fusion/adapted/std_tuple.hpp>
namespace ircd::spirit
{
namespace spirit = boost::spirit;
namespace ascii = spirit::ascii;
namespace karma = spirit::karma;
namespace qi = spirit::qi;
using spirit::unused_type;
using qi::lit;
using qi::char_;
using qi::string;
using qi::short_;
using qi::int_;
using qi::long_;
using qi::double_;
using qi::raw;
using qi::omit;
using qi::matches;
using qi::hold;
using qi::eoi;
using qi::eps;
using qi::attr;
using qi::attr_cast;
using qi::repeat;
using qi::_r1_type;
using karma::lit;
using karma::char_;
using karma::long_;
using karma::double_;
using karma::bool_;
using karma::eps;
using karma::attr_cast;
using karma::maxwidth;
using karma::buffer;
}

View file

@ -21,18 +21,7 @@ BOOST_FUSION_ADAPT_STRUCT
namespace ircd { namespace ircd {
namespace fmt { namespace fmt {
namespace qi = boost::spirit::qi; using namespace ircd::spirit;
namespace karma = boost::spirit::karma;
using qi::lit;
using qi::char_;
using qi::ushort_;
using qi::int_;
using qi::eps;
using qi::raw;
using qi::repeat;
using qi::omit;
using qi::unused_type;
std::map<string_view, specifier *, std::less<>> _specifiers; std::map<string_view, specifier *, std::less<>> _specifiers;

View file

@ -12,25 +12,7 @@
namespace ircd::http namespace ircd::http
{ {
namespace spirit = boost::spirit; using namespace ircd::spirit;
namespace qi = spirit::qi;
namespace karma = spirit::karma;
namespace ascii = qi::ascii;
using qi::lit;
using qi::string;
using qi::char_;
using qi::short_;
using qi::int_;
using qi::long_;
using qi::repeat;
using qi::omit;
using qi::raw;
using qi::attr;
using qi::eps;
using qi::attr_cast;
using karma::maxwidth;
using spirit::unused_type;
template<class it, class top = unused_type> struct grammar; template<class it, class top = unused_type> struct grammar;
struct parser extern const parser; struct parser extern const parser;

View file

@ -13,34 +13,7 @@
namespace ircd::json namespace ircd::json
{ {
namespace spirit = boost::spirit; using namespace ircd::spirit;
namespace ascii = spirit::ascii;
namespace karma = spirit::karma;
namespace qi = spirit::qi;
using spirit::unused_type;
using qi::lit;
using qi::char_;
using qi::long_;
using qi::double_;
using qi::raw;
using qi::omit;
using qi::matches;
using qi::hold;
using qi::eoi;
using qi::eps;
using qi::attr;
using qi::repeat;
using qi::_r1_type;
using karma::lit;
using karma::char_;
using karma::long_;
using karma::double_;
using karma::bool_;
using karma::eps;
using karma::attr_cast;
template<class it> struct input; template<class it> struct input;
template<class it> struct output; template<class it> struct output;

View file

@ -13,43 +13,16 @@
namespace ircd::m namespace ircd::m
{ {
namespace spirit = boost::spirit; using namespace ircd::spirit;
namespace qi = spirit::qi;
namespace karma = spirit::karma;
namespace ascii = qi::ascii;
using qi::lit;
using qi::string;
using qi::char_;
using qi::short_;
using qi::ushort_;
using qi::int_;
using qi::long_;
using qi::repeat;
using qi::omit;
using qi::raw;
using qi::attr;
using qi::eps;
using qi::eoi;
using qi::attr_cast;
using karma::lit;
using karma::char_;
using karma::long_;
using karma::double_;
using karma::bool_;
using karma::maxwidth;
using karma::eps;
using karma::attr_cast;
[[noreturn]] void failure(const qi::expectation_failure<const char *> &, const string_view &); [[noreturn]] void failure(const qi::expectation_failure<const char *> &, const string_view &);
} }
template<class it> template<class it>
struct ircd::m::id::input struct ircd::m::id::input
:qi::grammar<it, spirit::unused_type> :qi::grammar<it, unused_type>
{ {
template<class R = spirit::unused_type, class... S> using rule = qi::rule<it, R, S...>; template<class R = unused_type, class... S> using rule = qi::rule<it, R, S...>;
// Sigils // Sigils
const rule<m::id::sigil> event_id_sigil { lit(char(m::id::EVENT)) ,"event_id sigil" }; const rule<m::id::sigil> event_id_sigil { lit(char(m::id::EVENT)) ,"event_id sigil" };
@ -252,9 +225,9 @@ struct ircd::m::id::input
template<class it> template<class it>
struct ircd::m::id::output struct ircd::m::id::output
:karma::grammar<it, spirit::unused_type> :karma::grammar<it, unused_type>
{ {
template<class T = spirit::unused_type> using rule = karma::rule<it, T>; template<class T = unused_type> using rule = karma::rule<it, T>;
output() output()
:output::base_type{rule<>{}} :output::base_type{rule<>{}}

View file

@ -12,21 +12,11 @@
namespace ircd::rfc1459 namespace ircd::rfc1459
{ {
namespace spirit = boost::spirit; using namespace ircd::spirit;
namespace karma = spirit::karma;
namespace qi = spirit::qi;
} }
namespace ircd::rfc1459::parse namespace ircd::rfc1459::parse
{ {
using qi::lit;
using qi::char_;
using qi::repeat;
using qi::attr;
using qi::eps;
using qi::raw;
using qi::omit;
template<class it, class top> struct grammar; template<class it, class top> struct grammar;
struct capstan extern const capstan; struct capstan extern const capstan;
struct head extern const head; struct head extern const head;
@ -34,11 +24,7 @@ namespace ircd::rfc1459::parse
namespace ircd::rfc1459::gen namespace ircd::rfc1459::gen
{ {
using karma::lit; using ircd::spirit::buffer;
using karma::int_;
using karma::char_;
using karma::buffer;
using karma::repeat;
template<class it, class top> struct grammar; template<class it, class top> struct grammar;
} }
@ -438,11 +424,14 @@ try
qi::parse(start, stop, grammar, *this); qi::parse(start, stop, grammar, *this);
} }
catch(const boost::spirit::qi::expectation_failure<const char *> &e) catch(const qi::expectation_failure<const char *> &e)
{ {
throw syntax_error("@%d expecting :%s", throw syntax_error
int(e.last - e.first), {
string(e.what_).c_str()); "@%d expecting :%s",
int(e.last - e.first),
ircd::string(e.what_).c_str()
};
} }
bool bool

View file

@ -10,37 +10,18 @@
#include <ircd/spirit.h> #include <ircd/spirit.h>
namespace spirit = boost::spirit;
namespace qi = spirit::qi;
namespace karma = spirit::karma;
namespace ascii = qi::ascii;
using qi::lit;
using qi::string;
using qi::char_;
using qi::short_;
using qi::ushort_;
using qi::int_;
using qi::long_;
using qi::repeat;
using qi::omit;
using qi::raw;
using qi::attr;
using qi::eps;
using qi::attr_cast;
using karma::maxwidth;
namespace ircd::rfc3986 namespace ircd::rfc3986
{ {
using namespace ircd::spirit;
template<class it> struct grammar; template<class it> struct grammar;
} }
template<class it> template<class it>
struct ircd::rfc3986::grammar struct ircd::rfc3986::grammar
:qi::grammar<it, spirit::unused_type> :qi::grammar<it, unused_type>
{ {
template<class R = spirit::unused_type, class... S> using rule = qi::rule<it, R, S...>; template<class R = unused_type, class... S> using rule = qi::rule<it, R, S...>;
const rule<> port const rule<> port
{ {
@ -206,7 +187,7 @@ ircd::rfc3986::encode(const string_view &url,
struct ircd::rfc3986::decoder struct ircd::rfc3986::decoder
:qi::grammar<const char *, mutable_buffer> :qi::grammar<const char *, mutable_buffer>
{ {
template<class R = spirit::unused_type, class... S> using rule = qi::rule<const char *, R, S...>; template<class R = unused_type, class... S> using rule = qi::rule<const char *, R, S...>;
rule<> url_illegal rule<> url_illegal
{ {