| Home | Libraries | People | FAQ | More

#### 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 parser 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.

Skipper

  The skip-parser type

Template Arguments

`Iterator`

  The iterator type you will use for parsing.

`A1`, `A2`, `A3`

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

Expression | Description
--- | ---
`rule<Iterator, A1, A2, A3> r(name);` | Rule declaration. `Iterator` 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 and error handling.
`rule<Iterator, A1, A2, A3> r(r2);` | Copy construct rule `r` from rule `r2`.
`r = r2;` | Assign rule `r2` to `r`.
`r.alias()` | return an alias of `r`. The alias is a parser that holds a reference to `r`. Reference semantics.
`r.copy()` | Get a copy of `r`.
`r.name(name)` | Naming a rule
`r.name()` | Getting the name of a rule
debug(r) | Debug rule `r`
`r = p;` | Rule definition
`r %= p;` | Auto-rule definition. The attribute of `p` should be compatible with the synthesized attribute of `r`. When `p` is successful, its attribute is automatically propagated to `r`'s synthesized attribute.
    template <typename Iterator>
    struct my_grammar : grammar<Iterator, A1, A2, A3>
    {
        my_grammar() : my_grammar::base_type(start, name)
        {
            // Rule definitions
            start = /* ... */;
        }

        rule<Iterator, A1, A2, A3> start;
        // more rule declarations...
    };
| Grammar definition. `name` is an optional string that gives the grammar its name, useful for debugging and error handling.
`g.name(name)` | Naming a grammar
`g.name()` | Getting the name of a grammar