bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Do not allow identifiers that start with a negative number.


From: Joel E. Denny
Subject: Re: [PATCH] Do not allow identifiers that start with a negative number.
Date: Sun, 9 Jan 2011 08:39:48 -0500 (EST)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

On Sat, 8 Jan 2011, Paul Eggert wrote:

>    $x--
> 
> is the same as
> 
>    $[x]--
> 
> for the same reason, even if "x--" is an identifier.  And, similarly,
> 
>    $--x
> 
> is invalid.

Yes.

> > Because Bison reparses the reference later to find "-" and ".".
> 
> Why does Bison need to reparse anything?  Bison can simply require,
> when it's doing the lexical analysis for $FOO, that FOO be
> a valid C identifier.  That is the essence of the above suggestion.
> And it should be very easy to do, much easier than any reparsing.

Because capturing the full sequence of characters that the user might have 
accidentally intended as part of the symbol name enables Bison to give 
more helpful errors and warnings.

> >   A symbol name can be any sequence of letters, underscores, periods, 
> >   dashes, and digits that does not start with an integer (unsigned
> >   or negative).
> > 
> > Is that clear enough?
> 
> It's clear for Bison identifiers per se, but it's not clear for
> the $FOO syntax.  Is the constraint on the $FOO identifiers described
> somewhere else?

Yes.  The feature is called named references.

> Even if so, it should be alluded to here, so that
> users know that C identifiers are in some sense "nicer" when choosing
> symbol names, since they can be used in the $FOO syntax.

Feel free to propose a patch.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]