...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The library implements a special API returning a parser instance for a supplied attribute type. This function finds the best matching parser type for the attribute based on a set of simple matching rules (as outlined in the table below) applied recursively to the attribute type. The returned parser can be utilized to match input for the provided attribute.
// forwards to <boost/spirit/home/qi/auto.hpp> #include <boost/spirit/include/qi_auto.hpp>
Also, see Include Structure.
Name |
---|
|
|
namespace boost { namespace spirit { namespace qi { template <typename Attr> inline <unspecified> create_parser(); }}}
The returned instance can be directly passed as the parser (or the skipping
parser) to any of the Spirit.Qi API functions. Additionally
it can be assigned to a rule as the rules right hand side expression.
This function will return a valid parser type only if the meta function
traits::create_parser_exists
returns mpl::true_
. Otherwise it will fail compiling.
namespace boost { namespace spirit { namespace traits { template <typename Attr> struct create_parser_exists; }}}
The meta function evaluates to mpl::true_
if create_parser
would
return a valid parser for the given type Attr
.
The following table outlines the mapping rules from the attribute type to the parser type. These rules are applied recursively to create the parser type which can be used to match input for the given attribute type.
Attribute type |
Generator type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Any (STL) container |
Kleene Star (unary |
Any Fusion sequence |
Sequence operator ( |
|
Optional operator (unary |
|
Alternative operator ( |
Important | |
---|---|
The mapping for the parsers |
Parameter |
Description |
---|---|
|
An attribute type utilized to create the corresponding parser type from. |