Plus Parser (+a)

| Home | Libraries | People | FAQ | More

##### Plus Parser (`+a`)

###### Description

The plus operator, `+a`, is a unary operator that matches its operand one or more times.

###### Header

    // forwards to <boost/spirit/home/qi/operator/plus.hpp>
    #include <boost/spirit/include/qi_plus.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` | Match `a` one or more times.

###### Attributes

See Compound Attribute Notation.

Expression | Attribute
--- | ---
`+a` |
    a: A --> +a: vector<A>
    a: Unused --> +a: Unused

###### Complexity

> The overall complexity of the Plus is defined by the complexity of its subject, `a`, multiplied by the number of repetitions. The complexity of the Plus itself is O(N), where N is the number successful repetitions.

###### Example

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

Some using declarations:

    using boost::spirit::ascii::alpha;
    using boost::spirit::qi::lexeme;

Parse one or more strings containing one or more alphabetic characters and put them in a vector:

    std::vector<std::string> attr;
    test_phrase_parser_attr("yaba daba doo", +lexeme[+alpha], attr);
    std::cout << attr[0] << ',' << attr[1] << ',' << attr[2] << std::endl;