...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The difference operator, a
- b
,
is a binary operator that matches the first (LHS) operand but not the
second (RHS). [8]
// forwards to <boost/spirit/home/qi/operator/difference.hpp> #include <boost/spirit/include/qi_difference.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 BinaryParser
.
Expression |
Semantics |
---|---|
|
Parse |
See Compound Attribute Notation.
Expression |
Attribute |
---|---|
|
a: A, b: B --> (a - b): A a: Unused, b: B --> (a - b): Unused
|
The complexity of the difference parser is defined by the sum of the complexities of both operands.
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 C/C++ style comment:
test_parser("/*A Comment*/", "/*" >> *(char_ - "*/") >> "*/");
[8]
Unlike classic Spirit, with Spirit2, the expression will always fail
if the RHS is a successful match regardless if the RHS matches less
characters. For example, the rule lit("policeman") - "police"
will always fail to
match. Spirit2 does not count the matching chars while parsing and
there is no reliable and fast way to check if the LHS matches more
than the RHS.