Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
Lazy (lazy)
Description

The lazy parser, as its name suggests, invokes a lazy Phoenix function that returns a parser at parse time. This parser will be used once it is created to continue the parse.

Header
// forwards to <boost/spirit/home/qi/auxiliary/lazy.hpp>
#include <boost/spirit/include/qi_lazy.hpp>

Also, see Include Structure.

Namespace

Name

boost::spirit::lazy // alias: boost::spirit::qi::lazy

Model of

Parser

Notation

fp

A Lazy Argument that evaluates to a Parser.

Expression Semantics

Semantics of an expression is defined only where it differs from, or is not defined in Parser.

Expression

Semantics

fp

Create a lazy-parser from a Lazy Argument, fp. fp will be invoked at parse time. fp is expected to return a Parser object. This parser is then invoked in order to parse the input.

lazy(fp)

Create a lazy-parser from a Lazy Argument, fp. fp will be invoked at parse time. fp is expected to return a Parser object. This parser is then invoked in order to parse the input.

Attributes

Expression

Attribute

fp

The attribute type of the return type of fp.

lazy(fp)

The attribute type of the return type of fp.

Complexity

The complexity of the lazy parser is determined by the complexity of the parser returned from fp.

Example
[Note] 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", val(string("Hello")));


PrevUpHomeNext