1 /*============================================================================= 2 Copyright (c) 2001-2003 Joel de Guzman 3 Copyright (c) 2001-2003 Daniel Nuffer 4 http://spirit.sourceforge.net/ 5 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 11 12 /////////////////////////////////////////////////////////////////////////////// 13 #include <boost/spirit/home/classic/namespace.hpp> 14 #include <boost/spirit/home/classic/utility/chset.hpp> 15 16 /////////////////////////////////////////////////////////////////////////////// 17 namespace boost { namespace spirit { 18 19 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN 20 21 /////////////////////////////////////////////////////////////////////////////// 22 // 23 // chset free operators 24 // 25 // Where a and b are both chsets, implements: 26 // 27 // a | b, a & b, a - b, a ^ b 28 // 29 // Where a is a chset, implements: 30 // 31 // ~a 32 // 33 /////////////////////////////////////////////////////////////////////////////// 34 template <typename CharT> 35 chset<CharT> 36 operator~(chset<CharT> const& a); 37 38 ////////////////////////////////// 39 template <typename CharT> 40 chset<CharT> 41 operator|(chset<CharT> const& a, chset<CharT> const& b); 42 43 ////////////////////////////////// 44 template <typename CharT> 45 chset<CharT> 46 operator&(chset<CharT> const& a, chset<CharT> const& b); 47 48 ////////////////////////////////// 49 template <typename CharT> 50 chset<CharT> 51 operator-(chset<CharT> const& a, chset<CharT> const& b); 52 53 ////////////////////////////////// 54 template <typename CharT> 55 chset<CharT> 56 operator^(chset<CharT> const& a, chset<CharT> const& b); 57 58 /////////////////////////////////////////////////////////////////////////////// 59 // 60 // range <--> chset free operators 61 // 62 // Where a is a chset and b is a range, and vice-versa, implements: 63 // 64 // a | b, a & b, a - b, a ^ b 65 // 66 /////////////////////////////////////////////////////////////////////////////// 67 template <typename CharT> 68 chset<CharT> 69 operator|(chset<CharT> const& a, range<CharT> const& b); 70 71 ////////////////////////////////// 72 template <typename CharT> 73 chset<CharT> 74 operator&(chset<CharT> const& a, range<CharT> const& b); 75 76 ////////////////////////////////// 77 template <typename CharT> 78 chset<CharT> 79 operator-(chset<CharT> const& a, range<CharT> const& b); 80 81 ////////////////////////////////// 82 template <typename CharT> 83 chset<CharT> 84 operator^(chset<CharT> const& a, range<CharT> const& b); 85 86 ////////////////////////////////// 87 template <typename CharT> 88 chset<CharT> 89 operator|(range<CharT> const& a, chset<CharT> const& b); 90 91 ////////////////////////////////// 92 template <typename CharT> 93 chset<CharT> 94 operator&(range<CharT> const& a, chset<CharT> const& b); 95 96 ////////////////////////////////// 97 template <typename CharT> 98 chset<CharT> 99 operator-(range<CharT> const& a, chset<CharT> const& b); 100 101 ////////////////////////////////// 102 template <typename CharT> 103 chset<CharT> 104 operator^(range<CharT> const& a, chset<CharT> const& b); 105 106 /////////////////////////////////////////////////////////////////////////////// 107 // 108 // chlit <--> chset free operators 109 // 110 // Where a is a chset and b is a chlit, and vice-versa, implements: 111 // 112 // a | b, a & b, a - b, a ^ b 113 // 114 /////////////////////////////////////////////////////////////////////////////// 115 template <typename CharT> 116 chset<CharT> 117 operator|(chset<CharT> const& a, chlit<CharT> const& b); 118 119 ////////////////////////////////// 120 template <typename CharT> 121 chset<CharT> 122 operator&(chset<CharT> const& a, chlit<CharT> const& b); 123 124 ////////////////////////////////// 125 template <typename CharT> 126 chset<CharT> 127 operator-(chset<CharT> const& a, chlit<CharT> const& b); 128 129 ////////////////////////////////// 130 template <typename CharT> 131 chset<CharT> 132 operator^(chset<CharT> const& a, chlit<CharT> const& b); 133 134 ////////////////////////////////// 135 template <typename CharT> 136 chset<CharT> 137 operator|(chlit<CharT> const& a, chset<CharT> const& b); 138 139 ////////////////////////////////// 140 template <typename CharT> 141 chset<CharT> 142 operator&(chlit<CharT> const& a, chset<CharT> const& b); 143 144 ////////////////////////////////// 145 template <typename CharT> 146 chset<CharT> 147 operator-(chlit<CharT> const& a, chset<CharT> const& b); 148 149 ////////////////////////////////// 150 template <typename CharT> 151 chset<CharT> 152 operator^(chlit<CharT> const& a, chset<CharT> const& b); 153 154 /////////////////////////////////////////////////////////////////////////////// 155 // 156 // negated_char_parser<range> <--> chset free operators 157 // 158 // Where a is a chset and b is a range, and vice-versa, implements: 159 // 160 // a | b, a & b, a - b, a ^ b 161 // 162 /////////////////////////////////////////////////////////////////////////////// 163 template <typename CharT> 164 chset<CharT> 165 operator|(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b); 166 167 ////////////////////////////////// 168 template <typename CharT> 169 chset<CharT> 170 operator&(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b); 171 172 ////////////////////////////////// 173 template <typename CharT> 174 chset<CharT> 175 operator-(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b); 176 177 ////////////////////////////////// 178 template <typename CharT> 179 chset<CharT> 180 operator^(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b); 181 182 ////////////////////////////////// 183 template <typename CharT> 184 chset<CharT> 185 operator|(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b); 186 187 ////////////////////////////////// 188 template <typename CharT> 189 chset<CharT> 190 operator&(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b); 191 192 ////////////////////////////////// 193 template <typename CharT> 194 chset<CharT> 195 operator-(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b); 196 197 ////////////////////////////////// 198 template <typename CharT> 199 chset<CharT> 200 operator^(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b); 201 202 /////////////////////////////////////////////////////////////////////////////// 203 // 204 // negated_char_parser<chlit> <--> chset free operators 205 // 206 // Where a is a chset and b is a chlit, and vice-versa, implements: 207 // 208 // a | b, a & b, a - b, a ^ b 209 // 210 /////////////////////////////////////////////////////////////////////////////// 211 template <typename CharT> 212 chset<CharT> 213 operator|(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b); 214 215 ////////////////////////////////// 216 template <typename CharT> 217 chset<CharT> 218 operator&(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b); 219 220 ////////////////////////////////// 221 template <typename CharT> 222 chset<CharT> 223 operator-(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b); 224 225 ////////////////////////////////// 226 template <typename CharT> 227 chset<CharT> 228 operator^(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b); 229 230 ////////////////////////////////// 231 template <typename CharT> 232 chset<CharT> 233 operator|(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b); 234 235 ////////////////////////////////// 236 template <typename CharT> 237 chset<CharT> 238 operator&(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b); 239 240 ////////////////////////////////// 241 template <typename CharT> 242 chset<CharT> 243 operator-(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b); 244 245 ////////////////////////////////// 246 template <typename CharT> 247 chset<CharT> 248 operator^(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b); 249 250 /////////////////////////////////////////////////////////////////////////////// 251 // 252 // literal primitives <--> chset free operators 253 // 254 // Where a is a chset and b is a literal primitive, 255 // and vice-versa, implements: 256 // 257 // a | b, a & b, a - b, a ^ b 258 // 259 /////////////////////////////////////////////////////////////////////////////// 260 template <typename CharT> 261 chset<CharT> 262 operator|(chset<CharT> const& a, CharT b); 263 264 ////////////////////////////////// 265 template <typename CharT> 266 chset<CharT> 267 operator&(chset<CharT> const& a, CharT b); 268 269 ////////////////////////////////// 270 template <typename CharT> 271 chset<CharT> 272 operator-(chset<CharT> const& a, CharT b); 273 274 ////////////////////////////////// 275 template <typename CharT> 276 chset<CharT> 277 operator^(chset<CharT> const& a, CharT b); 278 279 ////////////////////////////////// 280 template <typename CharT> 281 chset<CharT> 282 operator|(CharT a, chset<CharT> const& b); 283 284 ////////////////////////////////// 285 template <typename CharT> 286 chset<CharT> 287 operator&(CharT a, chset<CharT> const& b); 288 289 ////////////////////////////////// 290 template <typename CharT> 291 chset<CharT> 292 operator-(CharT a, chset<CharT> const& b); 293 294 ////////////////////////////////// 295 template <typename CharT> 296 chset<CharT> 297 operator^(CharT a, chset<CharT> const& b); 298 299 /////////////////////////////////////////////////////////////////////////////// 300 // 301 // anychar_parser <--> chset free operators 302 // 303 // Where a is chset and b is a anychar_parser, and vice-versa, implements: 304 // 305 // a | b, a & b, a - b, a ^ b 306 // 307 /////////////////////////////////////////////////////////////////////////////// 308 template <typename CharT> 309 chset<CharT> 310 operator|(chset<CharT> const& a, anychar_parser b); 311 312 ////////////////////////////////// 313 template <typename CharT> 314 chset<CharT> 315 operator&(chset<CharT> const& a, anychar_parser b); 316 317 ////////////////////////////////// 318 template <typename CharT> 319 chset<CharT> 320 operator-(chset<CharT> const& a, anychar_parser b); 321 322 ////////////////////////////////// 323 template <typename CharT> 324 chset<CharT> 325 operator^(chset<CharT> const& a, anychar_parser b); 326 327 ////////////////////////////////// 328 template <typename CharT> 329 chset<CharT> 330 operator|(anychar_parser a, chset<CharT> const& b); 331 332 ////////////////////////////////// 333 template <typename CharT> 334 chset<CharT> 335 operator&(anychar_parser a, chset<CharT> const& b); 336 337 ////////////////////////////////// 338 template <typename CharT> 339 chset<CharT> 340 operator-(anychar_parser a, chset<CharT> const& b); 341 342 ////////////////////////////////// 343 template <typename CharT> 344 chset<CharT> 345 operator^(anychar_parser a, chset<CharT> const& b); 346 347 /////////////////////////////////////////////////////////////////////////////// 348 // 349 // nothing_parser <--> chset free operators 350 // 351 // Where a is chset and b is nothing_parser, and vice-versa, implements: 352 // 353 // a | b, a & b, a - b, a ^ b 354 // 355 /////////////////////////////////////////////////////////////////////////////// 356 template <typename CharT> 357 chset<CharT> 358 operator|(chset<CharT> const& a, nothing_parser b); 359 360 ////////////////////////////////// 361 template <typename CharT> 362 chset<CharT> 363 operator&(chset<CharT> const& a, nothing_parser b); 364 365 ////////////////////////////////// 366 template <typename CharT> 367 chset<CharT> 368 operator-(chset<CharT> const& a, nothing_parser b); 369 370 ////////////////////////////////// 371 template <typename CharT> 372 chset<CharT> 373 operator^(chset<CharT> const& a, nothing_parser b); 374 375 ////////////////////////////////// 376 template <typename CharT> 377 chset<CharT> 378 operator|(nothing_parser a, chset<CharT> const& b); 379 380 ////////////////////////////////// 381 template <typename CharT> 382 chset<CharT> 383 operator&(nothing_parser a, chset<CharT> const& b); 384 385 ////////////////////////////////// 386 template <typename CharT> 387 chset<CharT> 388 operator-(nothing_parser a, chset<CharT> const& b); 389 390 ////////////////////////////////// 391 template <typename CharT> 392 chset<CharT> 393 operator^(nothing_parser a, chset<CharT> const& b); 394 395 /////////////////////////////////////////////////////////////////////////////// 396 BOOST_SPIRIT_CLASSIC_NAMESPACE_END 397 398 }} // namespace BOOST_SPIRIT_CLASSIC_NS 399 400 #endif 401 402 #include <boost/spirit/home/classic/utility/impl/chset_operators.ipp> 403