1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/spirit/utility/distinct.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,227 @@
1.4 +/*=============================================================================
1.5 + Copyright (c) 1998-2003 Joel de Guzman
1.6 + Copyright (c) 2003 Vaclav Vesely
1.7 + http://spirit.sourceforge.net/
1.8 +
1.9 + Use, modification and distribution is subject to the Boost Software
1.10 + License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
1.11 + http://www.boost.org/LICENSE_1_0.txt)
1.12 +=============================================================================*/
1.13 +#if !defined(BOOST_SPIRIT_DISTINCT_HPP)
1.14 +#define BOOST_SPIRIT_DISTINCT_HPP
1.15 +
1.16 +#include <boost/spirit/core/parser.hpp>
1.17 +#include <boost/spirit/core/primitives/primitives.hpp>
1.18 +#include <boost/spirit/core/composite/operators.hpp>
1.19 +#include <boost/spirit/core/composite/directives.hpp>
1.20 +#include <boost/spirit/core/composite/epsilon.hpp>
1.21 +#include <boost/spirit/core/non_terminal/rule.hpp>
1.22 +#include <boost/spirit/utility/chset.hpp>
1.23 +
1.24 +#include <boost/spirit/utility/distinct_fwd.hpp>
1.25 +
1.26 +namespace boost {
1.27 + namespace spirit {
1.28 +//-----------------------------------------------------------------------------
1.29 +// distinct_parser class
1.30 +
1.31 +template <typename CharT, typename TailT>
1.32 +class distinct_parser
1.33 +{
1.34 +public:
1.35 + typedef
1.36 + contiguous<
1.37 + sequence<
1.38 + chseq<CharT const*>,
1.39 + negated_empty_match_parser<
1.40 + TailT
1.41 + >
1.42 + >
1.43 + >
1.44 + result_t;
1.45 +
1.46 + distinct_parser()
1.47 + : tail(chset<CharT>())
1.48 + {
1.49 + }
1.50 +
1.51 + explicit distinct_parser(parser<TailT> const & tail_)
1.52 + : tail(tail_.derived())
1.53 + {
1.54 + }
1.55 +
1.56 + explicit distinct_parser(CharT const* letters)
1.57 + : tail(chset_p(letters))
1.58 + {
1.59 + }
1.60 +
1.61 + result_t operator()(CharT const* str) const
1.62 + {
1.63 + return lexeme_d[chseq_p(str) >> ~epsilon_p(tail)];
1.64 + }
1.65 +
1.66 + TailT tail;
1.67 +};
1.68 +
1.69 +//-----------------------------------------------------------------------------
1.70 +// distinct_directive class
1.71 +
1.72 +template <typename CharT, typename TailT>
1.73 +class distinct_directive
1.74 +{
1.75 +public:
1.76 + template<typename ParserT>
1.77 + struct result {
1.78 + typedef
1.79 + contiguous<
1.80 + sequence<
1.81 + ParserT,
1.82 + negated_empty_match_parser<
1.83 + TailT
1.84 + >
1.85 + >
1.86 + >
1.87 + type;
1.88 + };
1.89 +
1.90 + distinct_directive()
1.91 + : tail(chset<CharT>())
1.92 + {
1.93 + }
1.94 +
1.95 + explicit distinct_directive(CharT const* letters)
1.96 + : tail(chset_p(letters))
1.97 + {
1.98 + }
1.99 +
1.100 + explicit distinct_directive(parser<TailT> const & tail_)
1.101 + : tail(tail_.derived())
1.102 + {
1.103 + }
1.104 +
1.105 + template<typename ParserT>
1.106 + typename result<typename as_parser<ParserT>::type>::type
1.107 + operator[](ParserT const &subject) const
1.108 + {
1.109 + return
1.110 + lexeme_d[as_parser<ParserT>::convert(subject) >> ~epsilon_p(tail)];
1.111 + }
1.112 +
1.113 + TailT tail;
1.114 +};
1.115 +
1.116 +//-----------------------------------------------------------------------------
1.117 +// dynamic_distinct_parser class
1.118 +
1.119 +template <typename ScannerT>
1.120 +class dynamic_distinct_parser
1.121 +{
1.122 +public:
1.123 + typedef typename ScannerT::value_t char_t;
1.124 +
1.125 + typedef
1.126 + rule<
1.127 + typename no_actions_scanner<
1.128 + typename lexeme_scanner<ScannerT>::type
1.129 + >::type
1.130 + >
1.131 + tail_t;
1.132 +
1.133 + typedef
1.134 + contiguous<
1.135 + sequence<
1.136 + chseq<char_t const*>,
1.137 + negated_empty_match_parser<
1.138 + tail_t
1.139 + >
1.140 + >
1.141 + >
1.142 + result_t;
1.143 +
1.144 + dynamic_distinct_parser()
1.145 + : tail(nothing_p)
1.146 + {
1.147 + }
1.148 +
1.149 + template<typename ParserT>
1.150 + explicit dynamic_distinct_parser(parser<ParserT> const & tail_)
1.151 + : tail(tail_.derived())
1.152 + {
1.153 + }
1.154 +
1.155 + explicit dynamic_distinct_parser(char_t const* letters)
1.156 + : tail(chset_p(letters))
1.157 + {
1.158 + }
1.159 +
1.160 + result_t operator()(char_t const* str) const
1.161 + {
1.162 + return lexeme_d[chseq_p(str) >> ~epsilon_p(tail)];
1.163 + }
1.164 +
1.165 + tail_t tail;
1.166 +};
1.167 +
1.168 +//-----------------------------------------------------------------------------
1.169 +// dynamic_distinct_directive class
1.170 +
1.171 +template <typename ScannerT>
1.172 +class dynamic_distinct_directive
1.173 +{
1.174 +public:
1.175 + typedef typename ScannerT::value_t char_t;
1.176 +
1.177 + typedef
1.178 + rule<
1.179 + typename no_actions_scanner<
1.180 + typename lexeme_scanner<ScannerT>::type
1.181 + >::type
1.182 + >
1.183 + tail_t;
1.184 +
1.185 + template<typename ParserT>
1.186 + struct result {
1.187 + typedef
1.188 + contiguous<
1.189 + sequence<
1.190 + ParserT,
1.191 + negated_empty_match_parser<
1.192 + tail_t
1.193 + >
1.194 + >
1.195 + >
1.196 + type;
1.197 + };
1.198 +
1.199 + dynamic_distinct_directive()
1.200 + : tail(nothing_p)
1.201 + {
1.202 + }
1.203 +
1.204 + template<typename ParserT>
1.205 + explicit dynamic_distinct_directive(parser<ParserT> const & tail_)
1.206 + : tail(tail_.derived())
1.207 + {
1.208 + }
1.209 +
1.210 + explicit dynamic_distinct_directive(char_t const* letters)
1.211 + : tail(chset_p(letters))
1.212 + {
1.213 + }
1.214 +
1.215 + template<typename ParserT>
1.216 + typename result<typename as_parser<ParserT>::type>::type
1.217 + operator[](ParserT const &subject) const
1.218 + {
1.219 + return
1.220 + lexeme_d[as_parser<ParserT>::convert(subject) >> ~epsilon_p(tail)];
1.221 + }
1.222 +
1.223 + tail_t tail;
1.224 +};
1.225 +
1.226 +//-----------------------------------------------------------------------------
1.227 + } // namespace spirit
1.228 +} // namespace boost
1.229 +
1.230 +#endif // !defined(BOOST_SPIRIT_DISTINCT_HPP)