...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The permutation operator, a
^ b
,
matches one or more operands (a
,
b
, ... etc.) in any order:
a ^ b ^ ...
The operands are the elements in the permutation set. Each element in the permutation set may occur at most once, but not all elements of the given set need to be present. Note that by this definition, the permutation operator is not limited to strict permutations.
For example:
char_('a') ^ 'b' ^ 'c'
matches:
"a", "ab", "abc", "cba", "bca" ... etc.
// forwards to <boost/spirit/home/qi/operator/permutation.hpp> #include <boost/spirit/include/qi_permutation.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
|
The overall complexity of the permutation parser is defined by the sum of the complexities of its elements, s, multiplied by log s. The complexity of the permutation parser itself is O(N log N), where N is the number of elements.
Note | |
---|---|
The test harness for the example(s) below is presented in the Basics Examples section. |
Some using declarations:
using boost::spirit::ascii::char_;
Parse a string containing DNA codes (ACTG)
test_parser("ACTGGCTAGACT", *(char_('A') ^ 'C' ^ 'T' ^ 'G'));