| Home | Libraries | People | FAQ | More

#### Compound Attribute Rules

###### Notation

The notation we will use will be of the form:

    a: A, b: B, ... --> composite-expression: composite-attribute

`a`, `b`, etc. are the operands. `A`, `B`, etc. are the operand's attribute types. `composite-expression` is the expression involving the operands and `composite-attribute` is the resulting attribute type of the composite expression.

For instance:

    a: A, b: B --> (a >> b): tuple<A, B>

reads as: given, `a` and `b` are parsers, and `A` is the type of the attribute of `a`, and `B` is the type of the attribute of `b`, then the type of the attribute of `a >> b` will be `tuple<A, B>`.

| Important
In the attribute tables, we will use `vector<A>` and `tuple<A, B...>` as placeholders only. The notation of `vector<A>` stands for any STL container holding elements of type `A` and the notation `tuple<A, B...>` stands for any Boost.Fusion sequence holding `A`, `B`, ... etc. elements. Finally, `Unused` stands for `unused_type`.

###### Compound Parser Attribute Types

Expression | Attribute
--- | ---

`a >> b`

    a: A, b: B --> (a >> b): tuple<A, B>
    a: A, b: Unused --> (a >> b): A
    a: Unused, b: B --> (a >> b): B
    a: Unused, b: Unused --> (a >> b): Unused

    a: A, b: A --> (a >> b): vector<A>
    a: vector<A>, b: A --> (a >> b): vector<A>
    a: A, b: vector<A> --> (a >> b): vector<A>
    a: vector<A>, b: vector<A> --> (a >> b): vector<A>

`a > b`

    a: A, b: B --> (a > b): tuple<A, B>
    a: A, b: Unused --> (a > b): A
    a: Unused, b: B --> (a > b): B
    a: Unused, b: Unused --> (a > b): Unused

    a: A, b: A --> (a > b): vector<A>
    a: vector<A>, b: A --> (a > b): vector<A>
    a: A, b: vector<A> --> (a > b): vector<A>
    a: vector<A>, b: vector<A> --> (a > b): vector<A>

`a | b`

    a: A, b: B --> (a | b): variant<A, B>
    a: A, b: Unused --> (a | b): optional<A>
    a: A, b: B, c: Unused --> (a | b | c): optional<variant<A, B> >
    a: Unused, b: B --> (a | b): optional<B>
    a: Unused, b: Unused --> (a | b): Unused
    a: A, b: A --> (a | b): A

`a - b`

    a: A, b: B --> (a - b): A
    a: Unused, b: B --> (a - b): Unused

`*a`

    a: A --> *a: vector<A>
    a: Unused --> *a: Unused

`+a`

    a: A --> +a: vector<A>
    a: Unused --> +a: Unused

`a % b`

    a: A, b: B --> (a % b): vector<A>
    a: Unused, b: B --> (a % b): Unused

`repeat(...,...)[a]`

    a: A --> repeat(...,...)[a]: vector<A>
    a: Unused --> repeat(...,...)[a]: Unused

`a || b`

    a: A, b: B --> (a || b): tuple<optional<A>, optional<B> >
    a: A, b: Unused --> (a || b): optional<A>
    a: Unused, b: B --> (a || b): optional<B>
    a: Unused, b: Unused --> (a || b): Unused

    a: A, b: A --> (a || b): vector<optional<A> >

`-a`

    a: A --> -a: optional<A>
    a: Unused --> -a: Unused

`&a` | `a: A --> &a: Unused`
`!b` | `a: A --> !a: Unused`

`a ^ b`

    a: A, b: B --> (a ^ b): tuple<optional<A>, optional<B> >
    a: A, b: Unused --> (a ^ b): optional<A>
    a: Unused, b: B --> (a ^ b): optional<B>
    a: Unused, b: Unused --> (a ^ b): Unused