File indexing completed on 2025-01-31 10:01:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #if !defined(BOOST_SPIRIT_SEQUENCE_HPP)
0011 #define BOOST_SPIRIT_SEQUENCE_HPP
0012
0013 #include <boost/spirit/home/classic/namespace.hpp>
0014 #include <boost/spirit/home/classic/core/parser.hpp>
0015 #include <boost/spirit/home/classic/core/primitives/primitives.hpp>
0016 #include <boost/spirit/home/classic/core/composite/composite.hpp>
0017 #include <boost/spirit/home/classic/meta/as_parser.hpp>
0018
0019 namespace boost { namespace spirit {
0020
0021 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 struct sequence_parser_gen;
0038
0039 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
0040 #pragma warning(push)
0041 #pragma warning(disable:4512)
0042 #endif
0043
0044 template <typename A, typename B>
0045 struct sequence : public binary<A, B, parser<sequence<A, B> > >
0046 {
0047 typedef sequence<A, B> self_t;
0048 typedef binary_parser_category parser_category_t;
0049 typedef sequence_parser_gen parser_generator_t;
0050 typedef binary<A, B, parser<self_t> > base_t;
0051
0052 sequence(A const& a, B const& b)
0053 : base_t(a, b) {}
0054
0055 template <typename ScannerT>
0056 typename parser_result<self_t, ScannerT>::type
0057 parse(ScannerT const& scan) const
0058 {
0059 typedef typename parser_result<self_t, ScannerT>::type result_t;
0060 if (result_t ma = this->left().parse(scan))
0061 if (result_t mb = this->right().parse(scan))
0062 {
0063 scan.concat_match(ma, mb);
0064 return ma;
0065 }
0066 return scan.no_match();
0067 }
0068 };
0069
0070 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
0071 #pragma warning(pop)
0072 #endif
0073
0074 struct sequence_parser_gen
0075 {
0076 template <typename A, typename B>
0077 struct result
0078 {
0079 typedef
0080 sequence<
0081 typename as_parser<A>::type
0082 , typename as_parser<B>::type
0083 >
0084 type;
0085 };
0086
0087 template <typename A, typename B>
0088 static sequence<
0089 typename as_parser<A>::type
0090 , typename as_parser<B>::type
0091 >
0092 generate(A const& a, B const& b)
0093 {
0094 return sequence<BOOST_DEDUCED_TYPENAME as_parser<A>::type,
0095 BOOST_DEDUCED_TYPENAME as_parser<B>::type>
0096 (as_parser<A>::convert(a), as_parser<B>::convert(b));
0097 }
0098 };
0099
0100 template <typename A, typename B>
0101 sequence<A, B>
0102 operator>>(parser<A> const& a, parser<B> const& b);
0103
0104 template <typename A>
0105 sequence<A, chlit<char> >
0106 operator>>(parser<A> const& a, char b);
0107
0108 template <typename B>
0109 sequence<chlit<char>, B>
0110 operator>>(char a, parser<B> const& b);
0111
0112 template <typename A>
0113 sequence<A, strlit<char const*> >
0114 operator>>(parser<A> const& a, char const* b);
0115
0116 template <typename B>
0117 sequence<strlit<char const*>, B>
0118 operator>>(char const* a, parser<B> const& b);
0119
0120 template <typename A>
0121 sequence<A, chlit<wchar_t> >
0122 operator>>(parser<A> const& a, wchar_t b);
0123
0124 template <typename B>
0125 sequence<chlit<wchar_t>, B>
0126 operator>>(wchar_t a, parser<B> const& b);
0127
0128 template <typename A>
0129 sequence<A, strlit<wchar_t const*> >
0130 operator>>(parser<A> const& a, wchar_t const* b);
0131
0132 template <typename B>
0133 sequence<strlit<wchar_t const*>, B>
0134 operator>>(wchar_t const* a, parser<B> const& b);
0135
0136 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0137
0138 }}
0139
0140 #endif
0141
0142 #include <boost/spirit/home/classic/core/composite/impl/sequence.ipp>