...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The sequentialor operator, a
 b
,
matches a
or b
or a
followed by b
. That is,
if both a
and b
match, it must be in sequence; this
is equivalent to a >>
b
 b
:
a  b  ...
// forwards to <boost/spirit/home/qi/operator/sequential_or.hpp> #include <boost/spirit/include/qi_sequential_or.hpp>
Also, see Include Structure.
Notation
a
,
b
A Parser
Semantics of an expression is defined only where it differs from, or
is not defined in NaryParser
.
Expression 
Semantics 


Match 
See Compound Attribute Notation.
Expression 
Attribute 


a: A, b: B > (a  b): tuple<optional<A>, optional<B> > a: A, b: Unused > (a  b): optional<A> a: Unused, b: B > (a  b): optional<B> a: Unused, b: Unused > (a  b): Unused a: A, b: A > (a  b): vector<optional<A> >

Note  

The sequentialor parser behaves attributewise very similar to the
plain sequence parser ( (int_  int_)[print_pair(_1, _2)]
the function object 
The overall complexity of the sequentialor parser is defined by the sum of the complexities of its elements. The complexity of the sequentialor itself is O(N), where N is the number of elements in the sequence.
Note  

The test harness for the example(s) below is presented in the Basics Examples section. 
Some using declarations:
using boost::spirit::qi::int_;
Correctly parsing a number with optional fractional digits:
test_parser("123.456", int_  ('.' >> int_)); // full test_parser("123", int_  ('.' >> int_)); // just the whole number test_parser(".456", int_  ('.' >> int_)); // just the fraction
A naive but incorrect solution would try to do this using optionals (e.g.):
int_ >> ('.' >> int_) // will not match ".456" int_ >> ('.' >> int_) // will not match "123" int_ >> ('.' >> int_) // will match empty strings! Ooops.