Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2001-05-30 13:21:16


On Wednesday 30 May 2001 02:08 pm, you wrote:
> From: "joel de guzman"
>
> > Rule<> a, c;
> > Rule<> b = c | a;
> > a = ...
> > b = ...
>
> Sorry this is wrong, cannot redefine b once
> defined. Well in fact I could have allowed that.
> Example:
>
> a = b;
> a = c;
> a = d;
>
> Equivalent to:
>
> a = b | c | d;
>
> But there's a runtime penalty.
>
> Have a nice day,
> Joel de Guzman

How significant would this runtime penalty be? It would be _extremely_ useful
to be able to, for instance, turn on/off extensions to a language at the
parser level, e.g.,

if (allow_typeof) {
  typespec = TYPEOF '(' expr ')' | TYPEOF '(' type_id ')';
}

if (allow_template_typedefs) {
  type_decl = template_header typedef;
}

That way one could have a very pure grammar for strict conformance to a
language and not worry so much about having extensions break the grammar
while running in a mode that does not allow the extensions at all. Why bother
to flag an error on use of extensions in the semantic actions if they
shouldn't be in the grammar at all?

        Doug


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