1 /*=============================================================================
2 Copyright (c) 2001-2003 Joel de Guzman
3 Copyright (c) 2001-2003 Daniel Nuffer
4 http://spirit.sourceforge.net/
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #ifndef BOOST_SPIRIT_CHSET_OPERATORS_HPP
10 #define BOOST_SPIRIT_CHSET_OPERATORS_HPP
12 ///////////////////////////////////////////////////////////////////////////////
13 #include <boost/spirit/home/classic/namespace.hpp>
14 #include <boost/spirit/home/classic/utility/chset.hpp>
16 ///////////////////////////////////////////////////////////////////////////////
17 namespace boost { namespace spirit {
19 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
21 ///////////////////////////////////////////////////////////////////////////////
23 // chset free operators
25 // Where a and b are both chsets, implements:
27 // a | b, a & b, a - b, a ^ b
29 // Where a is a chset, implements:
33 ///////////////////////////////////////////////////////////////////////////////
34 template <typename CharT>
36 operator~(chset<CharT> const& a);
38 //////////////////////////////////
39 template <typename CharT>
41 operator|(chset<CharT> const& a, chset<CharT> const& b);
43 //////////////////////////////////
44 template <typename CharT>
46 operator&(chset<CharT> const& a, chset<CharT> const& b);
48 //////////////////////////////////
49 template <typename CharT>
51 operator-(chset<CharT> const& a, chset<CharT> const& b);
53 //////////////////////////////////
54 template <typename CharT>
56 operator^(chset<CharT> const& a, chset<CharT> const& b);
58 ///////////////////////////////////////////////////////////////////////////////
60 // range <--> chset free operators
62 // Where a is a chset and b is a range, and vice-versa, implements:
64 // a | b, a & b, a - b, a ^ b
66 ///////////////////////////////////////////////////////////////////////////////
67 template <typename CharT>
69 operator|(chset<CharT> const& a, range<CharT> const& b);
71 //////////////////////////////////
72 template <typename CharT>
74 operator&(chset<CharT> const& a, range<CharT> const& b);
76 //////////////////////////////////
77 template <typename CharT>
79 operator-(chset<CharT> const& a, range<CharT> const& b);
81 //////////////////////////////////
82 template <typename CharT>
84 operator^(chset<CharT> const& a, range<CharT> const& b);
86 //////////////////////////////////
87 template <typename CharT>
89 operator|(range<CharT> const& a, chset<CharT> const& b);
91 //////////////////////////////////
92 template <typename CharT>
94 operator&(range<CharT> const& a, chset<CharT> const& b);
96 //////////////////////////////////
97 template <typename CharT>
99 operator-(range<CharT> const& a, chset<CharT> const& b);
101 //////////////////////////////////
102 template <typename CharT>
104 operator^(range<CharT> const& a, chset<CharT> const& b);
106 ///////////////////////////////////////////////////////////////////////////////
108 // chlit <--> chset free operators
110 // Where a is a chset and b is a chlit, and vice-versa, implements:
112 // a | b, a & b, a - b, a ^ b
114 ///////////////////////////////////////////////////////////////////////////////
115 template <typename CharT>
117 operator|(chset<CharT> const& a, chlit<CharT> const& b);
119 //////////////////////////////////
120 template <typename CharT>
122 operator&(chset<CharT> const& a, chlit<CharT> const& b);
124 //////////////////////////////////
125 template <typename CharT>
127 operator-(chset<CharT> const& a, chlit<CharT> const& b);
129 //////////////////////////////////
130 template <typename CharT>
132 operator^(chset<CharT> const& a, chlit<CharT> const& b);
134 //////////////////////////////////
135 template <typename CharT>
137 operator|(chlit<CharT> const& a, chset<CharT> const& b);
139 //////////////////////////////////
140 template <typename CharT>
142 operator&(chlit<CharT> const& a, chset<CharT> const& b);
144 //////////////////////////////////
145 template <typename CharT>
147 operator-(chlit<CharT> const& a, chset<CharT> const& b);
149 //////////////////////////////////
150 template <typename CharT>
152 operator^(chlit<CharT> const& a, chset<CharT> const& b);
154 ///////////////////////////////////////////////////////////////////////////////
156 // negated_char_parser<range> <--> chset free operators
158 // Where a is a chset and b is a range, and vice-versa, implements:
160 // a | b, a & b, a - b, a ^ b
162 ///////////////////////////////////////////////////////////////////////////////
163 template <typename CharT>
165 operator|(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b);
167 //////////////////////////////////
168 template <typename CharT>
170 operator&(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b);
172 //////////////////////////////////
173 template <typename CharT>
175 operator-(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b);
177 //////////////////////////////////
178 template <typename CharT>
180 operator^(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b);
182 //////////////////////////////////
183 template <typename CharT>
185 operator|(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b);
187 //////////////////////////////////
188 template <typename CharT>
190 operator&(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b);
192 //////////////////////////////////
193 template <typename CharT>
195 operator-(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b);
197 //////////////////////////////////
198 template <typename CharT>
200 operator^(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b);
202 ///////////////////////////////////////////////////////////////////////////////
204 // negated_char_parser<chlit> <--> chset free operators
206 // Where a is a chset and b is a chlit, and vice-versa, implements:
208 // a | b, a & b, a - b, a ^ b
210 ///////////////////////////////////////////////////////////////////////////////
211 template <typename CharT>
213 operator|(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b);
215 //////////////////////////////////
216 template <typename CharT>
218 operator&(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b);
220 //////////////////////////////////
221 template <typename CharT>
223 operator-(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b);
225 //////////////////////////////////
226 template <typename CharT>
228 operator^(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b);
230 //////////////////////////////////
231 template <typename CharT>
233 operator|(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b);
235 //////////////////////////////////
236 template <typename CharT>
238 operator&(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b);
240 //////////////////////////////////
241 template <typename CharT>
243 operator-(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b);
245 //////////////////////////////////
246 template <typename CharT>
248 operator^(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b);
250 ///////////////////////////////////////////////////////////////////////////////
252 // literal primitives <--> chset free operators
254 // Where a is a chset and b is a literal primitive,
255 // and vice-versa, implements:
257 // a | b, a & b, a - b, a ^ b
259 ///////////////////////////////////////////////////////////////////////////////
260 template <typename CharT>
262 operator|(chset<CharT> const& a, CharT b);
264 //////////////////////////////////
265 template <typename CharT>
267 operator&(chset<CharT> const& a, CharT b);
269 //////////////////////////////////
270 template <typename CharT>
272 operator-(chset<CharT> const& a, CharT b);
274 //////////////////////////////////
275 template <typename CharT>
277 operator^(chset<CharT> const& a, CharT b);
279 //////////////////////////////////
280 template <typename CharT>
282 operator|(CharT a, chset<CharT> const& b);
284 //////////////////////////////////
285 template <typename CharT>
287 operator&(CharT a, chset<CharT> const& b);
289 //////////////////////////////////
290 template <typename CharT>
292 operator-(CharT a, chset<CharT> const& b);
294 //////////////////////////////////
295 template <typename CharT>
297 operator^(CharT a, chset<CharT> const& b);
299 ///////////////////////////////////////////////////////////////////////////////
301 // anychar_parser <--> chset free operators
303 // Where a is chset and b is a anychar_parser, and vice-versa, implements:
305 // a | b, a & b, a - b, a ^ b
307 ///////////////////////////////////////////////////////////////////////////////
308 template <typename CharT>
310 operator|(chset<CharT> const& a, anychar_parser b);
312 //////////////////////////////////
313 template <typename CharT>
315 operator&(chset<CharT> const& a, anychar_parser b);
317 //////////////////////////////////
318 template <typename CharT>
320 operator-(chset<CharT> const& a, anychar_parser b);
322 //////////////////////////////////
323 template <typename CharT>
325 operator^(chset<CharT> const& a, anychar_parser b);
327 //////////////////////////////////
328 template <typename CharT>
330 operator|(anychar_parser a, chset<CharT> const& b);
332 //////////////////////////////////
333 template <typename CharT>
335 operator&(anychar_parser a, chset<CharT> const& b);
337 //////////////////////////////////
338 template <typename CharT>
340 operator-(anychar_parser a, chset<CharT> const& b);
342 //////////////////////////////////
343 template <typename CharT>
345 operator^(anychar_parser a, chset<CharT> const& b);
347 ///////////////////////////////////////////////////////////////////////////////
349 // nothing_parser <--> chset free operators
351 // Where a is chset and b is nothing_parser, and vice-versa, implements:
353 // a | b, a & b, a - b, a ^ b
355 ///////////////////////////////////////////////////////////////////////////////
356 template <typename CharT>
358 operator|(chset<CharT> const& a, nothing_parser b);
360 //////////////////////////////////
361 template <typename CharT>
363 operator&(chset<CharT> const& a, nothing_parser b);
365 //////////////////////////////////
366 template <typename CharT>
368 operator-(chset<CharT> const& a, nothing_parser b);
370 //////////////////////////////////
371 template <typename CharT>
373 operator^(chset<CharT> const& a, nothing_parser b);
375 //////////////////////////////////
376 template <typename CharT>
378 operator|(nothing_parser a, chset<CharT> const& b);
380 //////////////////////////////////
381 template <typename CharT>
383 operator&(nothing_parser a, chset<CharT> const& b);
385 //////////////////////////////////
386 template <typename CharT>
388 operator-(nothing_parser a, chset<CharT> const& b);
390 //////////////////////////////////
391 template <typename CharT>
393 operator^(nothing_parser a, chset<CharT> const& b);
395 ///////////////////////////////////////////////////////////////////////////////
396 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
398 }} // namespace BOOST_SPIRIT_CLASSIC_NS
402 #include <boost/spirit/home/classic/utility/impl/chset_operators.ipp>