This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug: gcc/cp/parse.y & gcc/cp/decl.h: Conflict on TYPENAME


| On Tue, Jun 18, 2002 at 11:13:01AM +0200, Akim Demaille wrote:
| > Zack> That'll work - however, it is not documented that %{ %} can come
| > Zack> after %union, nor that YYSTYPE is then available in that case,
| > Zack> nor that multiple %{ %} blocks are necessary.  I can provide a
| > Zack> documentation patch if you would like.
| > 
| > That would be nice.
| 
| Appended (vs. that 1.49b tarball you sent).

Thanks, I'm applying it.

| 
| > Good to know.  I'm curious: I wonder how other Yaccs handle this
| > problem.  It would be easy to solve if the user were required to use
| > YYSTYPE* only, but it is not the case :(
| 
| Well, the copy of byacc I have doesn't have any support for stack
| enlargement on overflow, so the question doesn't arise.

Sorry for being unclear: I was referring to the %union visibility
problem in %{ %}, not to yyoverflow.  But now I remember: they simply
output %union when it is met, so they preserve the order, just as
Bison does:

    /tmp % cat foo.y                                                 
    %{
      foo-before
    %}
    %union
    {
      foo-inside
    }
    %{
      foo-after
    %}
    %%
    exp:;
    %%

    /tmp % byacc foo.y                                               
    /tmp % fgrep foo y.tab.c                                         
    #line 2 "foo.y"
      foo-before
    #line 4 "foo.y"
      foo-inside
    #line 9 "foo.y"
      foo-after

    /tmp % bison foo.y                                               
    /tmp % fgrep foo foo.tab.c                                       
    /* A Bison parser, made from foo.y
    #line 1 "foo.y"
      foo-before
    #line 5 "foo.y"
      foo-inside
    #line 80 "foo.tab.c"
    #line 8 "foo.y"
      foo-after
    #line 104 "foo.tab.c"
    #line 921 "foo.tab.c"
    #line 13 "foo.y"
    


| 	* doc/bison.texinfo: Document ability to have multiple
| 	prologue sections.
| 
| --- doc/bison.texinfo~	Sat May 25 09:02:11 2002
| +++ doc/bison.texinfo	Tue Jun 18 12:42:29 2002
| @@ -2055,6 +2055,33 @@
|  need any C declarations, you may omit the @samp{%@{} and @samp{%@}}
|  delimiters that bracket this section.
|  
| +You may have more than one @var{Prologue} section, intermixed with the
| +@var{Bison declarations}.  This allows you to have C and Bison
| +declarations that refer to each other.  For example, the @code{%union}
| +declaration may use types defined in a header file, and you may wish to
| +prototype functions that take arguments of type @code{YYSTYPE}.  This
| +can be done with two @var{Prologue} blocks, one before and one after the
| +@code{%union} declaration.
| +
| +@smallexample
| +%@{
| +#include <stdio.h>
| +#include "ptypes.h"
| +%@}
| +
| +%union @{
| +  long n;
| +  tree t;  /* @r{@code{tree} is defined in @file{ptypes.h}.} */
| +@}
| +
| +%@{
| +static void yyprint(FILE *, int, YYSTYPE);
| +#define YYPRINT(F, N, L) yyprint(F, N, L)
| +%@}
| +
| +@dots{}
| +@end smallexample
| +
|  @node Bison Declarations
|  @subsection The Bison Declarations Section
|  @cindex Bison declarations (introduction)
| 


Thanks, I'm applying it.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]