Directive for Transduction Parsing (raw[])

| Home | Libraries | People | FAQ | More

##### Directive for Transduction Parsing (`raw[]`)

###### Description

The `raw[]` disregards the attribute of its subject parser, instead exposing the half-open range `[first, last)` pointing to the matched characters from the input stream. The `raw[]` directive brings back the classic Spirit transduction (un-attributed) behavior for a subject parser.

###### Header

    // forwards to <boost/spirit/home/qi/directive/raw.hpp>
    #include <boost/spirit/include/qi_raw.hpp>

Also, see Include Structure.

###### Namespace

Name
`boost::spirit::raw // alias: boost::spirit::qi::raw`

###### Model of

> `UnaryParser`

Notation

`a`

  A `Parser`.

`Iter`

  A `ForwardIterator` type.

###### Expression Semantics

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

Expression | Semantics
--- | ---
`raw[a]` | Disregard the attribute of the subject parser, `a`. Expose instead the half-open range `[first, last)` pointing to the matched characters from the input stream.

###### Attributes

See Compound Attribute Notation.

Expression | Attribute
--- | ---

`raw[a]`

    a: A --> raw[a]: boost::iterator_range<Iter>
    a: Unused --> raw[a]: Unused

| Note
See `boost::iterator_range`.

###### Complexity

> The complexity is defined by the complexity of the subject parser, `a`

###### Example

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

Some using declarations:

    using boost::spirit::qi::raw;
    using boost::spirit::ascii::alpha;
    using boost::spirit::ascii::alnum;

This parser matches and extracts C++ identifiers:

    std::string id;
    test_parser_attr("James007", raw[(alpha | '_') >> *(alnum | '_')], id);
    std::cout << id << std::endl; // should print James007