bison-patches
[Top][All Lists]
Advanced

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

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


From: Akim Demaille
Subject: Re: Bug: gcc/cp/parse.y & gcc/cp/decl.h: Conflict on TYPENAME
Date: 19 Jun 2002 09:44:19 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

| 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 @address@hidden and @address@hidden
|  delimiters that bracket this section.
|  
| +You may have more than one @var{Prologue} section, intermixed with the
| address@hidden 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
| address@hidden declaration.
| +
| address@hidden
| address@hidden
| +#include <stdio.h>
| +#include "ptypes.h"
| address@hidden
| +
| +%union @{
| +  long n;
| +  tree t;  /* @address@hidden is defined in @file{ptypes.h}.} */
| address@hidden
| +
| address@hidden
| +static void yyprint(FILE *, int, YYSTYPE);
| +#define YYPRINT(F, N, L) yyprint(F, N, L)
| address@hidden
| +
| address@hidden
| address@hidden smallexample
| +
|  @node Bison Declarations
|  @subsection The Bison Declarations Section
|  @cindex Bison declarations (introduction)
| 


Thanks, I'm applying it.



reply via email to

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