File indexing completed on 2025-01-31 10:02:07
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_SPIRIT_LISTS_IPP
0010 #define BOOST_SPIRIT_LISTS_IPP
0011
0012
0013 #include <boost/spirit/home/classic/meta/refactoring.hpp>
0014
0015
0016 namespace boost { namespace spirit {
0017
0018 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0019
0020
0021
0022
0023
0024
0025 struct no_list_endtoken { typedef no_list_endtoken embed_t; };
0026
0027 namespace impl {
0028
0029
0030
0031
0032
0033
0034
0035
0036 template <typename EndT>
0037 struct select_list_parse_refactor {
0038
0039 template <
0040 typename ParserT, typename ScannerT,
0041 typename ItemT, typename DelimT
0042 >
0043 static typename parser_result<ParserT, ScannerT>::type
0044 parse(ScannerT const& scan, ParserT const& ,
0045 ItemT const &item, DelimT const &delim, EndT const &end)
0046 {
0047 typedef refactor_action_gen<refactor_unary_gen<> > refactor_t;
0048 const refactor_t refactor_item_d = refactor_t(refactor_unary_d);
0049
0050 return (
0051 refactor_item_d[item - (end | delim)]
0052 >> *(delim >> refactor_item_d[item - (end | delim)])
0053 >> !(delim >> end)
0054 ).parse(scan);
0055 }
0056 };
0057
0058
0059 template <>
0060 struct select_list_parse_refactor<no_list_endtoken> {
0061
0062 template <
0063 typename ParserT, typename ScannerT,
0064 typename ItemT, typename DelimT
0065 >
0066 static typename parser_result<ParserT, ScannerT>::type
0067 parse(ScannerT const& scan, ParserT const& ,
0068 ItemT const &item, DelimT const &delim, no_list_endtoken const&)
0069 {
0070 typedef refactor_action_gen<refactor_unary_gen<> > refactor_t;
0071 const refactor_t refactor_item_d = refactor_t(refactor_unary_d);
0072
0073 return (
0074 refactor_item_d[item - delim]
0075 >> *(delim >> refactor_item_d[item - delim])
0076 ).parse(scan);
0077 }
0078 };
0079
0080
0081
0082
0083
0084
0085
0086
0087 template <typename EndT>
0088 struct select_list_parse_no_refactor {
0089
0090 template <
0091 typename ParserT, typename ScannerT,
0092 typename ItemT, typename DelimT
0093 >
0094 static typename parser_result<ParserT, ScannerT>::type
0095 parse(ScannerT const& scan, ParserT const& ,
0096 ItemT const &item, DelimT const &delim, EndT const &end)
0097 {
0098 return (
0099 (item - (end | delim))
0100 >> *(delim >> (item - (end | delim)))
0101 >> !(delim >> end)
0102 ).parse(scan);
0103 }
0104 };
0105
0106
0107 template <>
0108 struct select_list_parse_no_refactor<no_list_endtoken> {
0109
0110 template <
0111 typename ParserT, typename ScannerT,
0112 typename ItemT, typename DelimT
0113 >
0114 static typename parser_result<ParserT, ScannerT>::type
0115 parse(ScannerT const& scan, ParserT const& ,
0116 ItemT const &item, DelimT const &delim, no_list_endtoken const&)
0117 {
0118 return (
0119 (item - delim)
0120 >> *(delim >> (item - delim))
0121 ).parse(scan);
0122 }
0123 };
0124
0125
0126
0127
0128 template <typename CategoryT>
0129 struct list_parser_type {
0130
0131 template <
0132 typename ParserT, typename ScannerT,
0133 typename ItemT, typename DelimT, typename EndT
0134 >
0135 static typename parser_result<ParserT, ScannerT>::type
0136 parse(ScannerT const& scan, ParserT const& p,
0137 ItemT const &item, DelimT const &delim, EndT const &end)
0138 {
0139 return select_list_parse_refactor<EndT>::
0140 parse(scan, p, item, delim, end);
0141 }
0142 };
0143
0144 template <>
0145 struct list_parser_type<plain_parser_category> {
0146
0147 template <
0148 typename ParserT, typename ScannerT,
0149 typename ItemT, typename DelimT, typename EndT
0150 >
0151 static typename parser_result<ParserT, ScannerT>::type
0152 parse(ScannerT const& scan, ParserT const& p,
0153 ItemT const &item, DelimT const &delim, EndT const &end)
0154 {
0155 return select_list_parse_no_refactor<EndT>::
0156 parse(scan, p, item, delim, end);
0157 }
0158 };
0159
0160 }
0161
0162
0163 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0164
0165 }}
0166
0167 #endif
0168