...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The lazy
parser, as its
name suggests, invokes a lazy Boost.Phoenix
function that returns a parser at parse time. This parser will be used
once it is created to continue the parse.
// forwards to <boost/spirit/home/qi/auxiliary/lazy.hpp> #include <boost/spirit/include/qi_lazy.hpp>
Also, see Include Structure.
Name |
---|
|
Notation
fp
A Lazy
Argument that evaluates to a Parser
.
Semantics of an expression is defined only where it differs from, or
is not defined in Parser
.
Expression |
Semantics |
---|---|
|
Create a lazy-parser from a Lazy
Argument, |
|
Create a lazy-parser from a Lazy
Argument, |
Expression |
Attribute |
---|---|
|
The attribute type of the return type of |
|
The attribute type of the return type of |
The complexity of the lazy
parser is determined by the complexity of the parser returned from fp
.
Note | |
---|---|
The test harness for the example(s) below is presented in the Basics Examples section. |
Some using declarations:
using boost::spirit::qi::lazy; using boost::spirit::ascii::string; using boost::phoenix::val;
Using lazy
:
Here, the phoenix::val expression creates a function that returns its argument when invoked. The lazy expression defers the invocation of this function at parse time. Then, this parser (string parser) is called into action. All this takes place at parse time.
test_parser("Hello", lazy(val(string("Hello"))));
The above is equivalent to:
test_parser("Hello", string("Hello"));