1
/*=============================================================================
3
Copyright (c) 1998-2003 Joel de Guzman
4
Copyright (c) 2001 Daniel Nuffer
5
http://spirit.sourceforge.net/
7
Permission to copy, use, modify, sell and distribute this software is
8
granted provided this copyright notice appears in all copies. This
9
software is provided "as is" without express or implied warranty, and
10
with no claim as to its suitability for any purpose.
11
=============================================================================*/
12
#if !defined(BOOST_SPIRIT_OPERATORS_HPP)
13
#define BOOST_SPIRIT_OPERATORS_HPP
15
///////////////////////////////////////////////////////////////////////////////
18
#include "boost/spirit/core/parser.hpp"
19
#include "boost/spirit/core/primitives/primitives.hpp"
20
#include "boost/spirit/core/composite/composite.hpp"
21
#include "boost/spirit/core/meta/impl/parser_type.hpp"
23
///////////////////////////////////////////////////////////////////////////////
24
namespace boost { namespace spirit {
26
///////////////////////////////////////////////////////////////////////////////
30
// Handles expressions of the form:
34
// where a and b are parsers. The expression returns a composite
35
// parser that matches a and b in sequence. One (not both) of the
36
// operands may be a literal char, wchar_t or a primitive string
37
// char const*, wchar_t const*.
39
///////////////////////////////////////////////////////////////////////////////
40
struct sequence_parser_gen;
42
template <typename A, typename B>
43
struct sequence : public binary<A, B, parser<sequence<A, B> > >
45
typedef sequence<A, B> self_t;
46
typedef binary_parser_category parser_category_t;
47
typedef sequence_parser_gen parser_generator_t;
48
typedef binary<A, B, parser<self_t> > base_t;
52
sequence(A const& a, B const& b)
55
template <typename ScannerT>
56
typename parser_result<self_t, ScannerT>::type
57
parse(ScannerT const& scan) const
59
typedef typename parser_result<self_t, ScannerT>::type result_t;
60
if (result_t ma = this->left().parse(scan))
61
if (result_t mb = this->right().parse(scan))
63
scan.concat_match(ma, mb);
66
return scan.no_match();
70
//////////////////////////////////
71
struct sequence_parser_gen
73
template <typename A, typename B>
77
sequence<typename as_parser<A>::type, typename as_parser<B>::type>
81
template <typename A, typename B>
82
static sequence<typename as_parser<A>::type, typename as_parser<B>::type>
83
generate(A const& a, B const& b)
85
return sequence<BOOST_SPIRIT_TYPENAME as_parser<A>::type,
86
BOOST_SPIRIT_TYPENAME as_parser<B>::type>
87
(as_parser<A>::convert(a), as_parser<B>::convert(b));
91
//////////////////////////////////
92
template <typename A, typename B>
94
operator>>(parser<A> const& a, parser<B> const& b);
96
//////////////////////////////////
98
sequence<A, chlit<char> >
99
operator>>(parser<A> const& a, char b);
101
//////////////////////////////////
102
template <typename B>
103
sequence<chlit<char>, B>
104
operator>>(char a, parser<B> const& b);
106
//////////////////////////////////
107
template <typename A>
108
sequence<A, strlit<char const*> >
109
operator>>(parser<A> const& a, char const* b);
111
//////////////////////////////////
112
template <typename B>
113
sequence<strlit<char const*>, B>
114
operator>>(char const* a, parser<B> const& b);
116
//////////////////////////////////
117
template <typename A>
118
sequence<A, chlit<wchar_t> >
119
operator>>(parser<A> const& a, wchar_t b);
121
//////////////////////////////////
122
template <typename B>
123
sequence<chlit<wchar_t>, B>
124
operator>>(wchar_t a, parser<B> const& b);
126
//////////////////////////////////
127
template <typename A>
128
sequence<A, strlit<wchar_t const*> >
129
operator>>(parser<A> const& a, wchar_t const* b);
131
//////////////////////////////////
132
template <typename B>
133
sequence<strlit<wchar_t const*>, B>
134
operator>>(wchar_t const* a, parser<B> const& b);
136
///////////////////////////////////////////////////////////////////////////////
138
// sequential-and operators
140
// Handles expressions of the form:
146
///////////////////////////////////////////////////////////////////////////////
147
template <typename A, typename B>
149
operator&&(parser<A> const& a, parser<B> const& b);
151
//////////////////////////////////
152
template <typename A>
153
sequence<A, chlit<char> >
154
operator&&(parser<A> const& a, char b);
156
//////////////////////////////////
157
template <typename B>
158
sequence<chlit<char>, B>
159
operator&&(char a, parser<B> const& b);
161
//////////////////////////////////
162
template <typename A>
163
sequence<A, strlit<char const*> >
164
operator&&(parser<A> const& a, char const* b);
166
//////////////////////////////////
167
template <typename B>
168
sequence<strlit<char const*>, B>
169
operator&&(char const* a, parser<B> const& b);
171
//////////////////////////////////
172
template <typename A>
173
sequence<A, chlit<wchar_t> >
174
operator&&(parser<A> const& a, wchar_t b);
176
//////////////////////////////////
177
template <typename B>
178
sequence<chlit<wchar_t>, B>
179
operator&&(wchar_t a, parser<B> const& b);
181
//////////////////////////////////
182
template <typename A>
183
sequence<A, strlit<wchar_t const*> >
184
operator&&(parser<A> const& a, wchar_t const* b);
186
//////////////////////////////////
187
template <typename B>
188
sequence<strlit<wchar_t const*>, B>
189
operator&&(wchar_t const* a, parser<B> const& b);
191
///////////////////////////////////////////////////////////////////////////////
193
// sequential-or class
195
// Handles expressions of the form:
203
// where a and b are parsers. The expression returns a composite
204
// parser that matches matches a or b in sequence. One (not both) of
205
// the operands may be a literal char, wchar_t or a primitive string
206
// char const*, wchar_t const*.
208
///////////////////////////////////////////////////////////////////////////////
209
struct sequential_or_parser_gen;
211
template <typename A, typename B>
212
struct sequential_or : public binary<A, B, parser<sequential_or<A, B> > >
214
typedef sequential_or<A, B> self_t;
215
typedef binary_parser_category parser_category_t;
216
typedef sequential_or_parser_gen parser_generator_t;
217
typedef binary<A, B, parser<self_t> > base_t;
220
: base_t(A(), B()) {}
221
sequential_or(A const& a, B const& b)
224
template <typename ScannerT>
225
typename parser_result<self_t, ScannerT>::type
226
parse(ScannerT const& scan) const
228
typedef typename parser_result<self_t, ScannerT>::type result_t;
229
typedef typename ScannerT::iterator_t iterator_t;
231
iterator_t save = scan.first;
232
if (result_t ma = this->left().parse(scan))
235
if (result_t mb = this->right().parse(scan))
238
scan.concat_match(ma, mb);
252
return this->right().parse(scan);
256
//////////////////////////////////
257
struct sequential_or_parser_gen
259
template <typename A, typename B>
262
typedef sequential_or<
263
typename as_parser<A>::type, typename as_parser<B>::type
267
template <typename A, typename B>
270
typename as_parser<A>::type,
271
typename as_parser<B>::type
273
generate(A const& a, B const& b)
275
return sequential_or<BOOST_SPIRIT_TYPENAME as_parser<A>::type,
276
BOOST_SPIRIT_TYPENAME as_parser<B>::type>
277
(as_parser<A>::convert(a), as_parser<B>::convert(b));
281
//////////////////////////////////
282
template <typename A, typename B>
284
operator||(parser<A> const& a, parser<B> const& b);
286
//////////////////////////////////
287
template <typename A>
288
sequential_or<A, chlit<char> >
289
operator||(parser<A> const& a, char b);
291
//////////////////////////////////
292
template <typename B>
293
sequential_or<chlit<char>, B>
294
operator||(char a, parser<B> const& b);
296
//////////////////////////////////
297
template <typename A>
298
sequential_or<A, strlit<char const*> >
299
operator||(parser<A> const& a, char const* b);
301
//////////////////////////////////
302
template <typename B>
303
sequential_or<strlit<char const*>, B>
304
operator||(char const* a, parser<B> const& b);
305
//////////////////////////////////
306
template <typename A>
307
sequential_or<A, chlit<wchar_t> >
308
operator||(parser<A> const& a, wchar_t b);
310
//////////////////////////////////
311
template <typename B>
312
sequential_or<chlit<wchar_t>, B>
313
operator||(wchar_t a, parser<B> const& b);
315
//////////////////////////////////
316
template <typename A>
317
sequential_or<A, strlit<wchar_t const*> >
318
operator||(parser<A> const& a, wchar_t const* b);
320
//////////////////////////////////
321
template <typename B>
322
sequential_or<strlit<wchar_t const*>, B>
323
operator||(wchar_t const* a, parser<B> const& b);
325
///////////////////////////////////////////////////////////////////////////////
329
// Handles expressions of the form:
333
// where a and b are parsers. The expression returns a composite
334
// parser that matches a or b. One (not both) of the operands may
335
// be a literal char, wchar_t or a primitive string char const*,
338
// The expression is short circuit evaluated. b is never touched
339
// when a is returns a successful match.
341
///////////////////////////////////////////////////////////////////////////////
342
struct alternative_parser_gen;
344
template <typename A, typename B>
346
: public binary<A, B, parser<alternative<A, B> > >
348
typedef alternative<A, B> self_t;
349
typedef binary_parser_category parser_category_t;
350
typedef alternative_parser_gen parser_generator_t;
351
typedef binary<A, B, parser<self_t> > base_t;
354
: base_t(A(), B()) {}
355
alternative(A const& a, B const& b)
358
template <typename ScannerT>
359
typename parser_result<self_t, ScannerT>::type
360
parse(ScannerT const& scan) const
362
typedef typename parser_result<self_t, ScannerT>::type result_t;
363
typedef typename ScannerT::iterator_t iterator_t;
365
iterator_t save = scan.first;
366
if (result_t hit = this->left().parse(scan))
370
return this->right().parse(scan);
374
//////////////////////////////////
375
struct alternative_parser_gen
377
template <typename A, typename B>
381
typename as_parser<A>::type, typename as_parser<B>::type
385
template <typename A, typename B>
388
typename as_parser<A>::type,
389
typename as_parser<B>::type
391
generate(A const& a, B const& b)
393
return alternative<BOOST_SPIRIT_TYPENAME as_parser<A>::type,
394
BOOST_SPIRIT_TYPENAME as_parser<B>::type>
395
(as_parser<A>::convert(a), as_parser<B>::convert(b));
399
//////////////////////////////////
400
template <typename A, typename B>
402
operator|(parser<A> const& a, parser<B> const& b);
404
//////////////////////////////////
405
template <typename A>
406
alternative<A, chlit<char> >
407
operator|(parser<A> const& a, char b);
409
//////////////////////////////////
410
template <typename B>
411
alternative<chlit<char>, B>
412
operator|(char a, parser<B> const& b);
414
//////////////////////////////////
415
template <typename A>
416
alternative<A, strlit<char const*> >
417
operator|(parser<A> const& a, char const* b);
419
//////////////////////////////////
420
template <typename B>
421
alternative<strlit<char const*>, B>
422
operator|(char const* a, parser<B> const& b);
424
//////////////////////////////////
425
template <typename A>
426
alternative<A, chlit<wchar_t> >
427
operator|(parser<A> const& a, wchar_t b);
429
//////////////////////////////////
430
template <typename B>
431
alternative<chlit<wchar_t>, B>
432
operator|(wchar_t a, parser<B> const& b);
434
//////////////////////////////////
435
template <typename A>
436
alternative<A, strlit<wchar_t const*> >
437
operator|(parser<A> const& a, wchar_t const* b);
439
//////////////////////////////////
440
template <typename B>
441
alternative<strlit<wchar_t const*>, B>
442
operator|(wchar_t const* a, parser<B> const& b);
444
///////////////////////////////////////////////////////////////////////////////
446
// intersection class
448
// Handles expressions of the form:
452
// where a and b are parsers. The expression returns a composite
453
// parser that matches a and b. One (not both) of the operands may
454
// be a literal char, wchar_t or a primitive string char const*,
457
// The expression is short circuit evaluated. b is never touched
458
// when a is returns a no-match.
460
///////////////////////////////////////////////////////////////////////////////
461
struct intersection_parser_gen;
463
template <typename A, typename B>
465
: public binary<A, B, parser<intersection<A, B> > >
467
typedef intersection<A, B> self_t;
468
typedef binary_parser_category parser_category_t;
469
typedef intersection_parser_gen parser_generator_t;
470
typedef binary<A, B, parser<self_t> > base_t;
473
: base_t(A(), B()) {}
474
intersection(A const& a, B const& b)
477
template <typename ScannerT>
478
typename parser_result<self_t, ScannerT>::type
479
parse(ScannerT const& scan) const
481
typedef typename parser_result<self_t, ScannerT>::type result_t;
482
typedef typename ScannerT::iterator_t iterator_t;
483
iterator_t save = scan.first;
484
if (result_t hl = this->left().parse(scan))
486
ScannerT bscan(scan.first, scan.first);
488
result_t hr = this->right().parse(bscan);
489
if (hl.length() == hr.length())
493
return scan.no_match();
497
//////////////////////////////////
498
struct intersection_parser_gen
500
template <typename A, typename B>
503
typedef intersection<
504
typename as_parser<A>::type, typename as_parser<B>::type
508
template <typename A, typename B>
511
typename as_parser<A>::type,
512
typename as_parser<B>::type
514
generate(A const& a, B const& b)
516
return intersection<BOOST_SPIRIT_TYPENAME as_parser<A>::type,
517
BOOST_SPIRIT_TYPENAME as_parser<B>::type>
518
(as_parser<A>::convert(a), as_parser<B>::convert(b));
522
//////////////////////////////////
523
template <typename A, typename B>
525
operator&(parser<A> const& a, parser<B> const& b);
527
//////////////////////////////////
528
template <typename A>
529
intersection<A, chlit<char> >
530
operator&(parser<A> const& a, char b);
532
//////////////////////////////////
533
template <typename B>
534
intersection<chlit<char>, B>
535
operator&(char a, parser<B> const& b);
537
//////////////////////////////////
538
template <typename A>
539
intersection<A, strlit<char const*> >
540
operator&(parser<A> const& a, char const* b);
542
//////////////////////////////////
543
template <typename B>
544
intersection<strlit<char const*>, B>
545
operator&(char const* a, parser<B> const& b);
547
//////////////////////////////////
548
template <typename A>
549
intersection<A, chlit<wchar_t> >
550
operator&(parser<A> const& a, wchar_t b);
552
//////////////////////////////////
553
template <typename B>
554
intersection<chlit<wchar_t>, B>
555
operator&(wchar_t a, parser<B> const& b);
557
//////////////////////////////////
558
template <typename A>
559
intersection<A, strlit<wchar_t const*> >
560
operator&(parser<A> const& a, wchar_t const* b);
562
//////////////////////////////////
563
template <typename B>
564
intersection<strlit<wchar_t const*>, B>
565
operator&(wchar_t const* a, parser<B> const& b);
567
///////////////////////////////////////////////////////////////////////////////
569
// difference: a - b; Matches a but not b
571
// Handles expressions of the form:
575
// where a and b are parsers. The expression returns a composite
576
// parser that matches a but not b. One (not both) of the operands
577
// may be a literal char, wchar_t or a primitive string char const*,
580
///////////////////////////////////////////////////////////////////////////////
581
struct difference_parser_gen;
583
template <typename A, typename B>
585
: public binary<A, B, parser<difference<A, B> > >
587
typedef difference<A, B> self_t;
588
typedef binary_parser_category parser_category_t;
589
typedef difference_parser_gen parser_generator_t;
590
typedef binary<A, B, parser<self_t> > base_t;
593
: base_t(A(), B()) {}
594
difference(A const& a, B const& b)
597
template <typename ScannerT>
598
typename parser_result<self_t, ScannerT>::type
599
parse(ScannerT const& scan) const
601
typedef typename parser_result<self_t, ScannerT>::type result_t;
602
typedef typename ScannerT::iterator_t iterator_t;
603
iterator_t save = scan.first;
604
if (result_t hl = this->left().parse(scan))
606
std::swap(save, scan.first);
607
result_t hr = this->right().parse(scan);
608
if (!hr || (hr.length() < hl.length()))
615
return scan.no_match();
619
//////////////////////////////////
620
struct difference_parser_gen
622
template <typename A, typename B>
626
typename as_parser<A>::type, typename as_parser<B>::type
630
template <typename A, typename B>
633
typename as_parser<A>::type,
634
typename as_parser<B>::type
636
generate(A const& a, B const& b)
638
return difference<BOOST_SPIRIT_TYPENAME as_parser<A>::type,
639
BOOST_SPIRIT_TYPENAME as_parser<B>::type>
640
(as_parser<A>::convert(a), as_parser<B>::convert(b));
644
//////////////////////////////////
645
template <typename A, typename B>
647
operator-(parser<A> const& a, parser<B> const& b);
649
//////////////////////////////////
650
template <typename A>
651
difference<A, chlit<char> >
652
operator-(parser<A> const& a, char b);
654
//////////////////////////////////
655
template <typename B>
656
difference<chlit<char>, B>
657
operator-(char a, parser<B> const& b);
659
//////////////////////////////////
660
template <typename A>
661
difference<A, strlit<char const*> >
662
operator-(parser<A> const& a, char const* b);
664
//////////////////////////////////
665
template <typename B>
666
difference<strlit<char const*>, B>
667
operator-(char const* a, parser<B> const& b);
669
//////////////////////////////////
670
template <typename A>
671
difference<A, chlit<wchar_t> >
672
operator-(parser<A> const& a, wchar_t b);
674
//////////////////////////////////
675
template <typename B>
676
difference<chlit<wchar_t>, B>
677
operator-(wchar_t a, parser<B> const& b);
679
//////////////////////////////////
680
template <typename A>
681
difference<A, strlit<wchar_t const*> >
682
operator-(parser<A> const& a, wchar_t const* b);
684
//////////////////////////////////
685
template <typename B>
686
difference<strlit<wchar_t const*>, B>
687
operator-(wchar_t const* a, parser<B> const& b);
689
///////////////////////////////////////////////////////////////////////////////
691
// exclusive_or class
693
// Handles expressions of the form:
697
// where a and b are parsers. The expression returns a composite
698
// parser that matches a or b but not both. One (not both) of the
699
// operands may be a literal char, wchar_t or a primitive string
700
// char const*, wchar_t const*.
702
///////////////////////////////////////////////////////////////////////////////
703
struct exclusive_or_parser_gen;
705
template <typename A, typename B>
707
: public binary<A, B, parser<exclusive_or<A, B> > >
709
typedef exclusive_or<A, B> self_t;
710
typedef binary_parser_category parser_category_t;
711
typedef exclusive_or_parser_gen parser_generator_t;
712
typedef binary<A, B, parser<self_t> > base_t;
715
: base_t(A(), B()) {}
716
exclusive_or(A const& a, B const& b)
719
template <typename ScannerT>
720
typename parser_result<self_t, ScannerT>::type
721
parse(ScannerT const& scan) const
723
typedef typename parser_result<self_t, ScannerT>::type result_t;
724
typedef typename ScannerT::iterator_t iterator_t;
726
iterator_t save = scan.first;
727
result_t l = this->left().parse(scan);
728
std::swap(save, scan.first);
729
result_t r = this->right().parse(scan);
731
if (bool(l) ^ bool(r))
735
return bool(l) ? l : r;
738
return scan.no_match();
742
//////////////////////////////////
743
struct exclusive_or_parser_gen
745
template <typename A, typename B>
748
typedef exclusive_or<
749
typename as_parser<A>::type, typename as_parser<B>::type
753
template <typename A, typename B>
756
typename as_parser<A>::type,
757
typename as_parser<B>::type
759
generate(A const& a, B const& b)
761
return exclusive_or<BOOST_SPIRIT_TYPENAME as_parser<A>::type,
762
BOOST_SPIRIT_TYPENAME as_parser<B>::type>
763
(as_parser<A>::convert(a), as_parser<B>::convert(b));
767
//////////////////////////////////
768
template <typename A, typename B>
770
operator^(parser<A> const& a, parser<B> const& b);
772
//////////////////////////////////
773
template <typename A>
774
exclusive_or<A, chlit<char> >
775
operator^(parser<A> const& a, char b);
777
//////////////////////////////////
778
template <typename B>
779
exclusive_or<chlit<char>, B>
780
operator^(char a, parser<B> const& b);
782
//////////////////////////////////
783
template <typename A>
784
exclusive_or<A, strlit<char const*> >
785
operator^(parser<A> const& a, char const* b);
787
//////////////////////////////////
788
template <typename B>
789
exclusive_or<strlit<char const*>, B>
790
operator^(char const* a, parser<B> const& b);
792
//////////////////////////////////
793
template <typename A>
794
exclusive_or<A, chlit<wchar_t> >
795
operator^(parser<A> const& a, wchar_t b);
797
//////////////////////////////////
798
template <typename B>
799
exclusive_or<chlit<wchar_t>, B>
800
operator^(wchar_t a, parser<B> const& b);
802
//////////////////////////////////
803
template <typename A>
804
exclusive_or<A, strlit<wchar_t const*> >
805
operator^(parser<A> const& a, wchar_t const* b);
807
//////////////////////////////////
808
template <typename B>
809
exclusive_or<strlit<wchar_t const*>, B>
810
operator^(wchar_t const* a, parser<B> const& b);
812
///////////////////////////////////////////////////////////////////////////////
816
// Handles expressions of the form:
820
// where a is a parser. The expression returns a composite
821
// parser that matches its subject zero (0) or one (1) time.
823
///////////////////////////////////////////////////////////////////////////////
824
struct optional_parser_gen;
826
template <typename S>
828
: public unary<S, parser<optional<S> > >
830
typedef optional<S> self_t;
831
typedef unary_parser_category parser_category_t;
832
typedef optional_parser_gen parser_generator_t;
833
typedef unary<S, parser<self_t> > base_t;
840
template <typename ScannerT>
841
typename parser_result<self_t, ScannerT>::type
842
parse(ScannerT const& scan) const
844
typedef typename parser_result<self_t, ScannerT>::type result_t;
845
typedef typename ScannerT::iterator_t iterator_t;
846
iterator_t save = scan.first;
847
if (result_t r = this->subject().parse(scan))
854
return scan.empty_match();
859
//////////////////////////////////
860
struct optional_parser_gen
862
template <typename S>
865
typedef optional<S> type;
868
template <typename S>
870
generate(parser<S> const& a)
872
return optional<S>(a.derived());
876
//////////////////////////////////
877
template <typename S>
879
operator!(parser<S> const& a);
881
///////////////////////////////////////////////////////////////////////////////
885
// Handles expressions of the form:
889
// where a is a parser. The expression returns a composite
890
// parser that matches its subject zero (0) or more times.
892
///////////////////////////////////////////////////////////////////////////////
893
struct kleene_star_parser_gen;
895
template <typename S>
897
: public unary<S, parser<kleene_star<S> > >
899
typedef kleene_star<S> self_t;
900
typedef unary_parser_category parser_category_t;
901
typedef kleene_star_parser_gen parser_generator_t;
902
typedef unary<S, parser<self_t> > base_t;
906
kleene_star(S const& a)
909
template <typename ScannerT>
910
typename parser_result<self_t, ScannerT>::type
911
parse(ScannerT const& scan) const
913
typedef typename parser_result<self_t, ScannerT>::type result_t;
914
typedef typename ScannerT::iterator_t iterator_t;
915
result_t hit = scan.empty_match();
919
iterator_t save = scan.first;
920
if (result_t next = this->subject().parse(scan))
922
scan.concat_match(hit, next);
933
//////////////////////////////////
934
struct kleene_star_parser_gen
936
template <typename S>
939
typedef kleene_star<S> type;
942
template <typename S>
943
static kleene_star<S>
944
generate(parser<S> const& a)
946
return kleene_star<S>(a.derived());
950
//////////////////////////////////
951
template <typename S>
953
operator*(parser<S> const& a);
955
///////////////////////////////////////////////////////////////////////////////
959
// Handles expressions of the form:
963
// where a is a parser. The expression returns a composite
964
// parser that matches its subject one (1) or more times.
966
///////////////////////////////////////////////////////////////////////////////
967
struct positive_parser_gen;
969
template <typename S>
971
: public unary<S, parser<positive<S> > >
973
typedef positive<S> self_t;
974
typedef unary_parser_category parser_category_t;
975
typedef positive_parser_gen parser_generator_t;
976
typedef unary<S, parser<self_t> > base_t;
983
template <typename ScannerT>
984
typename parser_result<self_t, ScannerT>::type
985
parse(ScannerT const& scan) const
987
typedef typename parser_result<self_t, ScannerT>::type result_t;
988
typedef typename ScannerT::iterator_t iterator_t;
989
result_t hit = this->subject().parse(scan);
995
iterator_t save = scan.first;
996
if (result_t next = this->subject().parse(scan))
998
scan.concat_match(hit, next);
1011
//////////////////////////////////
1012
struct positive_parser_gen
1014
template <typename S>
1017
typedef positive<S> type;
1020
template <typename S>
1022
generate(parser<S> const& a)
1024
return positive<S>(a.derived());
1028
//////////////////////////////////
1029
template <typename S>
1031
operator + (parser<S> const& a);
1033
///////////////////////////////////////////////////////////////////////////////
1035
// operator% is defined as:
1036
// a % b ---> a >> *(b >> a)
1038
///////////////////////////////////////////////////////////////////////////////
1039
template <typename A, typename B>
1040
sequence<A, kleene_star<sequence<B, A> > >
1041
operator%(parser<A> const& a, parser<B> const& b);
1043
//////////////////////////////////
1044
template <typename A>
1045
sequence<A, kleene_star<sequence<chlit<char>, A> > >
1046
operator%(parser<A> const& a, char b);
1048
//////////////////////////////////
1049
template <typename B>
1050
sequence<chlit<char>, kleene_star<sequence<B, chlit<char> > > >
1051
operator%(char a, parser<B> const& b);
1053
//////////////////////////////////
1054
template <typename A>
1055
sequence<A, kleene_star<sequence<strlit<char const*>, A> > >
1056
operator%(parser<A> const& a, char const* b);
1058
//////////////////////////////////
1059
template <typename B>
1060
sequence<strlit<char const*>,
1061
kleene_star<sequence<B, strlit<char const*> > > >
1062
operator%(char const* a, parser<B> const& b);
1064
//////////////////////////////////
1065
template <typename A>
1066
sequence<A, kleene_star<sequence<chlit<wchar_t>, A> > >
1067
operator%(parser<A> const& a, wchar_t b);
1069
//////////////////////////////////
1070
template <typename B>
1071
sequence<chlit<wchar_t>, kleene_star<sequence<B, chlit<wchar_t> > > >
1072
operator%(wchar_t a, parser<B> const& b);
1074
//////////////////////////////////
1075
template <typename A>
1076
sequence<A, kleene_star<sequence<strlit<wchar_t const*>, A> > >
1077
operator%(parser<A> const& a, wchar_t const* b);
1079
//////////////////////////////////
1080
template <typename B>
1081
sequence<strlit<wchar_t const*>,
1082
kleene_star<sequence<B, strlit<wchar_t const*> > > >
1083
operator%(wchar_t const* a, parser<B> const& b);
1085
///////////////////////////////////////////////////////////////////////////////
1086
}} // namespace boost::spirit
1090
#include "boost/spirit/core/composite/impl/operators.ipp"