Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2008-03-22 23:12:24


Larry Evans wrote:
> On 03/04/08 11:38, Eric Niebler wrote:
>> An expression is a grammar, but a grammar is not an expression. For
>> example, not_<X> is only a grammar and not an expression.
>>
>
> The following grammar I think summarizes the difference between
> grammar and expression:
>
> expr //describes an expression.
> = terminal
> | expr+
> //i.e. 1 or more expressions (e.g. expr<tag::plus,expr0,expr1>)
> ;

OK.

> gram //describes a grammar
> = expr
> | wildcard //struct wildcardns_::_ in matches.hpp
> | control //any struct or class template in namespace control in
> //matches.hpp
> ;

OK.

> control
> = not_ >> gram
> | or_ >> gram >> gram+
> | and_ >> gram >> gram+
> | if_ >> gram >> gram
> ;

I may have an issue with your notation here.

control
    = not_<gram>
    | or_<gram+>
    | and_<gram+>
    | if_<trans, gram, gram>
    // or a vararg expr, or switch_, or ...
    ;

> The '= expr' as first alternate of gram reflects the statement
> 'an expression is a grammar'. The absence of gram on the
> rhs of the expr equation reflects the statement 'a grammar
> is not an expression'.
>
> Is that about right?

Yes, you have it.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk