And-Predicate Parser (&a)

| Home | Libraries | People | FAQ | More

##### And-Predicate Parser (`&a`)

###### Description

Syntactic predicates assert a certain conditional syntax to be satisfied before evaluating another production. Similar to semantic predicates, `eps`, syntactic predicates do not consume any input. The and-predicate, `&a`, is a positive syntactic predicate that returns a zero length match only if its predicate matches.

###### Header

    // forwards to <boost/spirit/home/qi/operator/and_predicate.hpp>
    #include <boost/spirit/include/qi_and_predicate.hpp>

Also, see Include Structure.

###### Model of

> `UnaryParser`

Notation

`a`

  A `Parser`

###### Expression Semantics

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

Expression | Semantics
--- | ---
`&a` | If the predicate `a` matches, return a zero length match. Otherwise, fail.

###### Attributes

See Compound Attribute Notation.

Expression | Attribute
--- | ---
`&a` | `unused_type`

###### Complexity

> The complexity is defined by the complexity of the predicate, `a`

###### Example

| Note
The test harness for the example(s) below is presented in the Basics Examples section.

Some using declarations:

    using boost::spirit::lit;

Basic look-ahead example: make sure that the last character is a semicolon, but don't consume it, just peek at the next character:

    test_phrase_parser("Hello ;", lit("Hello") >> &lit(';'), false);