[Top][All Lists]

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

Re: quick bison Q

From: Paul Eggert
Subject: Re: quick bison Q
Date: Fri, 6 Dec 2002 10:37:18 -0800

> Date: Fri, 06 Dec 2002 09:29:19 -0600
> From: David Durham <address@hidden>
> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826
> I was wondering why
> %union foo
> {
> }
> doesn't work any more?  It doesn't like 'foo'

The Bison reader was redone recently, and my guess is that we didn't
know about this undocumented feature.  Also, POSIX does not require
support for this feature.  Instead of using "%union foo {...}", you
are supposed to do something like this:

    union foo { int ival;};
    #define YYSTYPE union foo

> the reason I need to name it is to be able to declare it as a friend
> of a C++ class.

Perhaps we should add this feature back to Bison, but I'd like to know
exactly what is needed.

In C, the only thing that can appear between the "union" and the "{"
is an optional identifier (also white space and comments, of course).
Is the same true for C++?

I have a language-lawyer question for you, since I don't use C++
myself.  In C++, what exactly can appear between the "union" and the
"{"?  Is it OK for Bison to restrict it to be a valid C identifier?
Here is the grammar for a valid C identifier:

  identifier = letter (letter | digit)*

  digit = [0-9]
  letter = [_a-zA-Z] | "\u" x x x x | "\U" x x x x x x x x | idl
  x = [0-9a-fA-F]
  idl = <implementation-defined letter>

A backslash-newline can be inserted between any two characters, but I
don't think Bison should have to worry about that.

Those "implementation-defined letters" worry me a bit, though, since
there's no easy way for Bison to discover whether a letter is allowed
by the implementation.

reply via email to

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