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

Nonterminals

See here for more information about Nonterminals.

Notation

RT

Synthesized attribute. The rule or grammar's return type.

Arg1, Arg2, ArgN

Inherited attributes. Zero or more arguments.

L1, L2, LN

Zero or more local variables.

r, r2

Rules

g

A grammar

p

A generator expression

my_grammar

A user defined grammar

Terminology

Signature

RT(Arg1, Arg2, ... ,ArgN). The signature specifies the synthesized (return value) and inherited (arguments) attributes.

Locals

locals<L1, L2, ..., LN>. The local variables.

Delimiter

The delimit-generator type

Template Arguments

Iterator

The iterator type you will use for parsing.

A1, A2, A3

Can be one of 1) Signature 2) Locals 3) Delimiter.

Expression

Description

rule<OutputIterator, A1, A2, A3> r(name);

Rule declaration. OutputIterator is required. A1, A2, A3 are optional and can be specified in any order. name is an optional string that gives the rule its name, useful for debugging.

rule<OutputIterator, A1, A2, A3> r(r2);

Copy construct rule r from rule r2.

r = r2;

Assign rule r2 to r. boost::shared_ptr semantics.

r.alias()

Return an alias of r. The alias is a generator that holds a reference to r. Reference semantics.

r.copy()

Get a copy of r.

r.name(name)

Set the name of a rule

r.name()

Get the name of a rule

debug(r)

Debug rule r

r = g;

Rule definition

r %= g;

Auto-rule definition. The attribute of g should be compatible with the synthesized attribute of r. When g is successful, its attribute is automatically propagated to r's synthesized attribute.

template <typename OutputIterator>
struct my_grammar : grammar<OutputIterator, A1, A2, A3>
{
    my_grammar() : my_grammar::base_type(start, name)
    {
        // Rule definitions
        start = /* ... */;
    }

    rule<OutputIterator, A1, A2, A3> start;
    // more rule declarations...
};

Grammar definition. name is an optional string that gives the grammar its name, useful for debugging.

my_grammar<OutputIterator> g

Instantiate a grammar

g.name(name)

Set the name of a grammar

g.name()

Get the name of a grammar


PrevUpHomeNext