123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927 |
- #ifndef BOOST_XPRESSIVE_REGEX_PRIMITIVES_HPP_EAN_10_04_2005
- #define BOOST_XPRESSIVE_REGEX_PRIMITIVES_HPP_EAN_10_04_2005
- #include <vector>
- #include <climits>
- #include <boost/config.hpp>
- #include <boost/assert.hpp>
- #include <boost/mpl/if.hpp>
- #include <boost/mpl/and.hpp>
- #include <boost/mpl/assert.hpp>
- #include <boost/detail/workaround.hpp>
- #include <boost/preprocessor/cat.hpp>
- #include <boost/xpressive/detail/detail_fwd.hpp>
- #include <boost/xpressive/detail/core/matchers.hpp>
- #include <boost/xpressive/detail/core/regex_domain.hpp>
- #include <boost/xpressive/detail/utility/ignore_unused.hpp>
- #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED
- # include <boost/proto/core.hpp>
- # include <boost/proto/transform/arg.hpp>
- # include <boost/proto/transform/when.hpp>
- # include <boost/xpressive/detail/core/icase.hpp>
- # include <boost/xpressive/detail/static/compile.hpp>
- # include <boost/xpressive/detail/static/modifier.hpp>
- #endif
- namespace boost { namespace xpressive { namespace detail
- {
- typedef assert_word_placeholder<word_boundary<mpl::true_> > assert_word_boundary;
- typedef assert_word_placeholder<word_begin> assert_word_begin;
- typedef assert_word_placeholder<word_end> assert_word_end;
-
-
- #if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
- #define mark_number(x) proto::call<mark_number(x)>
- #define minus_one() proto::make<minus_one()>
- #endif
- struct push_back : proto::callable
- {
- typedef int result_type;
- template<typename Subs>
- int operator ()(Subs &subs, int i) const
- {
- subs.push_back(i);
- return i;
- }
- };
- struct mark_number : proto::callable
- {
- typedef int result_type;
- template<typename Expr>
- int operator ()(Expr const &expr) const
- {
- return expr.mark_number_;
- }
- };
- typedef mpl::int_<-1> minus_one;
-
- struct SubMatch
- : proto::or_<
- proto::when<basic_mark_tag, push_back(proto::_data, mark_number(proto::_value)) >
- , proto::when<proto::negate<basic_mark_tag>, push_back(proto::_data, minus_one()) >
- >
- {};
- struct SubMatchList
- : proto::or_<SubMatch, proto::comma<SubMatchList, SubMatch> >
- {};
- template<typename Subs>
- typename enable_if<
- mpl::and_<proto::is_expr<Subs>, proto::matches<Subs, SubMatchList> >
- , std::vector<int>
- >::type
- to_vector(Subs const &subs)
- {
- std::vector<int> subs_;
- SubMatchList()(subs, 0, subs_);
- return subs_;
- }
- #if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
- #undef mark_number
- #undef minus_one
- #endif
-
- struct skip_primitives : proto::transform<skip_primitives>
- {
- template<typename Expr, typename State, typename Data>
- struct impl : proto::transform_impl<Expr, State, Data>
- {
- typedef
- typename proto::shift_right<
- typename proto::unary_expr<
- keeper_tag
- , typename proto::dereference<State>::type
- >::type
- , Expr
- >::type
- result_type;
- result_type operator ()(
- typename impl::expr_param expr
- , typename impl::state_param state
- , typename impl::data_param
- ) const
- {
- result_type that = {{{state}}, expr};
- return that;
- }
- };
- };
- struct Primitives
- : proto::or_<
- proto::terminal<proto::_>
- , proto::comma<proto::_, proto::_>
- , proto::subscript<proto::terminal<set_initializer>, proto::_>
- , proto::assign<proto::terminal<set_initializer>, proto::_>
- , proto::assign<proto::terminal<attribute_placeholder<proto::_> >, proto::_>
- , proto::complement<Primitives>
- >
- {};
- struct SkipGrammar
- : proto::or_<
- proto::when<Primitives, skip_primitives>
- , proto::assign<proto::terminal<mark_placeholder>, SkipGrammar>
- , proto::subscript<SkipGrammar, proto::_>
- , proto::binary_expr<modifier_tag, proto::_, SkipGrammar>
- , proto::unary_expr<lookbehind_tag, proto::_>
- , proto::nary_expr<proto::_, proto::vararg<SkipGrammar> >
- >
- {};
- template<typename Skip>
- struct skip_directive
- {
- typedef typename proto::result_of::as_expr<Skip>::type skip_type;
- skip_directive(Skip const &skip)
- : skip_(proto::as_expr(skip))
- {}
- template<typename Sig>
- struct result {};
- template<typename This, typename Expr>
- struct result<This(Expr)>
- {
- typedef
- SkipGrammar::impl<
- typename proto::result_of::as_expr<Expr>::type
- , skip_type const &
- , mpl::void_ &
- >
- skip_transform;
- typedef
- typename proto::shift_right<
- typename skip_transform::result_type
- , typename proto::dereference<skip_type>::type
- >::type
- type;
- };
- template<typename Expr>
- typename result<skip_directive(Expr)>::type
- operator ()(Expr const &expr) const
- {
- mpl::void_ ignore;
- typedef result<skip_directive(Expr)> result_fun;
- typename result_fun::type that = {
- typename result_fun::skip_transform()(proto::as_expr(expr), this->skip_, ignore)
- , {skip_}
- };
- return that;
- }
- private:
- skip_type skip_;
- };
- }
- unsigned int const repeat_max = UINT_MAX-1;
- unsigned int const inf = UINT_MAX-1;
- proto::terminal<detail::epsilon_matcher>::type const epsilon = {{}};
- proto::terminal<detail::epsilon_matcher>::type const nil = {{}};
- proto::terminal<detail::posix_charset_placeholder>::type const alnum = {{"alnum", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const alpha = {{"alpha", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const blank = {{"blank", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const cntrl = {{"cntrl", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const digit = {{"digit", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const graph = {{"graph", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const lower = {{"lower", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const print = {{"print", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const punct = {{"punct", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const space = {{"space", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const upper = {{"upper", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const xdigit = {{"xdigit", false}};
- proto::terminal<detail::assert_bos_matcher>::type const bos = {{}};
- proto::terminal<detail::assert_eos_matcher>::type const eos = {{}};
- proto::terminal<detail::assert_bol_placeholder>::type const bol = {{}};
- proto::terminal<detail::assert_eol_placeholder>::type const eol = {{}};
- proto::terminal<detail::assert_word_begin>::type const bow = {{}};
- proto::terminal<detail::assert_word_end>::type const eow = {{}};
- proto::terminal<detail::assert_word_boundary>::type const _b = {{}};
- proto::terminal<detail::posix_charset_placeholder>::type const _w = {{"w", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const _d = {{"d", false}};
- proto::terminal<detail::posix_charset_placeholder>::type const _s = {{"s", false}};
- proto::terminal<char>::type const _n = {'\n'};
- detail::logical_newline_xpression const _ln = {{}};
- proto::terminal<detail::any_matcher>::type const _ = {{}};
- proto::terminal<detail::self_placeholder>::type const self = {{}};
- detail::set_initializer_type const set = {{}};
- struct mark_tag
- : proto::extends<detail::basic_mark_tag, mark_tag, detail::regex_domain>
- {
- private:
- typedef proto::extends<detail::basic_mark_tag, mark_tag, detail::regex_domain> base_type;
- static detail::basic_mark_tag make_tag(int mark_nbr)
- {
- detail::basic_mark_tag mark = {{mark_nbr}};
- return mark;
- }
- public:
-
-
-
-
- mark_tag(int mark_nbr)
- : base_type(mark_tag::make_tag(mark_nbr))
- {
-
- BOOST_ASSERT(mark_nbr > 0);
- }
-
- operator detail::basic_mark_tag const &() const
- {
- return this->proto_base();
- }
- BOOST_PROTO_EXTENDS_USING_ASSIGN_NON_DEPENDENT(mark_tag)
- };
- #define BOOST_XPRESSIVE_GLOBAL_MARK_TAG(NAME, VALUE) \
- boost::xpressive::mark_tag::proto_base_expr const NAME = {{VALUE}} \
-
- BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s0, 0);
- BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s1, 1);
- BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s2, 2);
- BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s3, 3);
- BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s4, 4);
- BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s5, 5);
- BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s6, 6);
- BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s7, 7);
- BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s8, 8);
- BOOST_XPRESSIVE_GLOBAL_MARK_TAG(s9, 9);
- #ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
- template<typename Expr> detail::unspecified icase(Expr const &expr) { return 0; }
- #endif
- #ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
- template<typename Literal> detail::unspecified as_xpr(Literal const &literal) { return 0; }
- #else
- proto::functional::as_expr<> const as_xpr = {};
- #endif
- template<typename BidiIter>
- inline typename proto::terminal<reference_wrapper<basic_regex<BidiIter> const> >::type const
- by_ref(basic_regex<BidiIter> const &rex)
- {
- reference_wrapper<basic_regex<BidiIter> const> ref(rex);
- return proto::terminal<reference_wrapper<basic_regex<BidiIter> const> >::type::make(ref);
- }
- template<typename Char>
- inline typename proto::terminal<detail::range_placeholder<Char> >::type const
- range(Char ch_min, Char ch_max)
- {
- detail::range_placeholder<Char> that = {ch_min, ch_max, false};
- return proto::terminal<detail::range_placeholder<Char> >::type::make(that);
- }
- template<typename Expr>
- typename proto::result_of::make_expr<
- proto::tag::logical_not
- , proto::default_domain
- , Expr const &
- >::type const
- optional(Expr const &expr)
- {
- return proto::make_expr<
- proto::tag::logical_not
- , proto::default_domain
- >(boost::ref(expr));
- }
- template<unsigned int Min, unsigned int Max, typename Expr>
- typename proto::result_of::make_expr<
- detail::generic_quant_tag<Min, Max>
- , proto::default_domain
- , Expr const &
- >::type const
- repeat(Expr const &expr)
- {
- return proto::make_expr<
- detail::generic_quant_tag<Min, Max>
- , proto::default_domain
- >(boost::ref(expr));
- }
- template<unsigned int Count, typename Expr2>
- typename proto::result_of::make_expr<
- detail::generic_quant_tag<Count, Count>
- , proto::default_domain
- , Expr2 const &
- >::type const
- repeat(Expr2 const &expr2)
- {
- return proto::make_expr<
- detail::generic_quant_tag<Count, Count>
- , proto::default_domain
- >(boost::ref(expr2));
- }
- template<typename Expr>
- typename proto::result_of::make_expr<
- detail::keeper_tag
- , proto::default_domain
- , Expr const &
- >::type const
- keep(Expr const &expr)
- {
- return proto::make_expr<
- detail::keeper_tag
- , proto::default_domain
- >(boost::ref(expr));
- }
- template<typename Expr>
- typename proto::result_of::make_expr<
- detail::lookahead_tag
- , proto::default_domain
- , Expr const &
- >::type const
- before(Expr const &expr)
- {
- return proto::make_expr<
- detail::lookahead_tag
- , proto::default_domain
- >(boost::ref(expr));
- }
- template<typename Expr>
- typename proto::result_of::make_expr<
- detail::lookbehind_tag
- , proto::default_domain
- , Expr const &
- >::type const
- after(Expr const &expr)
- {
- return proto::make_expr<
- detail::lookbehind_tag
- , proto::default_domain
- >(boost::ref(expr));
- }
- template<typename Locale>
- inline detail::modifier_op<detail::locale_modifier<Locale> > const
- imbue(Locale const &loc)
- {
- detail::modifier_op<detail::locale_modifier<Locale> > mod =
- {
- detail::locale_modifier<Locale>(loc)
- , regex_constants::ECMAScript
- };
- return mod;
- }
- proto::terminal<detail::attribute_placeholder<mpl::int_<1> > >::type const a1 = {{}};
- proto::terminal<detail::attribute_placeholder<mpl::int_<2> > >::type const a2 = {{}};
- proto::terminal<detail::attribute_placeholder<mpl::int_<3> > >::type const a3 = {{}};
- proto::terminal<detail::attribute_placeholder<mpl::int_<4> > >::type const a4 = {{}};
- proto::terminal<detail::attribute_placeholder<mpl::int_<5> > >::type const a5 = {{}};
- proto::terminal<detail::attribute_placeholder<mpl::int_<6> > >::type const a6 = {{}};
- proto::terminal<detail::attribute_placeholder<mpl::int_<7> > >::type const a7 = {{}};
- proto::terminal<detail::attribute_placeholder<mpl::int_<8> > >::type const a8 = {{}};
- proto::terminal<detail::attribute_placeholder<mpl::int_<9> > >::type const a9 = {{}};
- template<typename Skip>
- detail::skip_directive<Skip> skip(Skip const &skip)
- {
- return detail::skip_directive<Skip>(skip);
- }
- namespace detail
- {
- inline void ignore_unused_regex_primitives()
- {
- detail::ignore_unused(repeat_max);
- detail::ignore_unused(inf);
- detail::ignore_unused(epsilon);
- detail::ignore_unused(nil);
- detail::ignore_unused(alnum);
- detail::ignore_unused(bos);
- detail::ignore_unused(eos);
- detail::ignore_unused(bol);
- detail::ignore_unused(eol);
- detail::ignore_unused(bow);
- detail::ignore_unused(eow);
- detail::ignore_unused(_b);
- detail::ignore_unused(_w);
- detail::ignore_unused(_d);
- detail::ignore_unused(_s);
- detail::ignore_unused(_n);
- detail::ignore_unused(_ln);
- detail::ignore_unused(_);
- detail::ignore_unused(self);
- detail::ignore_unused(set);
- detail::ignore_unused(s0);
- detail::ignore_unused(s1);
- detail::ignore_unused(s2);
- detail::ignore_unused(s3);
- detail::ignore_unused(s4);
- detail::ignore_unused(s5);
- detail::ignore_unused(s6);
- detail::ignore_unused(s7);
- detail::ignore_unused(s8);
- detail::ignore_unused(s9);
- detail::ignore_unused(a1);
- detail::ignore_unused(a2);
- detail::ignore_unused(a3);
- detail::ignore_unused(a4);
- detail::ignore_unused(a5);
- detail::ignore_unused(a6);
- detail::ignore_unused(a7);
- detail::ignore_unused(a8);
- detail::ignore_unused(a9);
- detail::ignore_unused(as_xpr);
- }
- }
- }}
- #endif
|