[Top][All Lists]

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

Re: Section 3.1.2 has what appears to be a bug

From: slipbits
Subject: Re: Section 3.1.2 has what appears to be a bug
Date: Mon, 20 Jun 2022 13:08:19 -0700
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0

Hi Kaz;

I''ll have to think about this some more. The quick take is that only %code import is available for use in D and Java. The remaining tags are for C/C++. If this is not correct then please correct me (sigh, having a dialog with someone who knows what he's talking about is such a humbling experience), and the User's Manual.

Here is my table of reason, which I hope is reasonable.

%code tag












Placed after all declarations

%code import






Placed in an importable class

%code provides





Placed after YYSTAB, YYLTYPE declaration

%code requires





Placed before YYSTAB, YYLTYPE declaration

%code top





Placed after Bison prologue and before %code require


On 6/19/2022 9:06 AM, Kaz Kylheku wrote:
On 2022-06-17 10:26, slipbits wrote:
3.1.2 Prologue Alternatives, pg. 50
    “and the new YYLTYPE definition before the Bison-generated YYSTYPE
    and YYLTYPE definitions in both the parser implementation file and
    the parser header file”.

    This position causes, in this case, YYLTYPE to be doubly defined in the 
same scope.

[ elided ]
Is this a bug?
There are ways in which both the header file and the parser source file
can independently provide a definition such that they don't clash:

   /* paste freely wherever you want, however many times you want */
   #ifndef FOO_DEFINED
   struct foo { int x; };
   #define FOO_DEFINED

The text refers to an example, and in that example this appears:

   typedef struct YYLTYPE
   { ...

in all likelihood, the Bison-generated skeleton code is checking for
the presence of the preprocessor symbol

You should try the example; if that doesn't work, then there is a bug.

I don't use YYLTYPE, but for YYSTYPE, Bison clearly generates
code like:

   if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
   typedef union YYSTYPE

Not sure about Java and other supported languages that don't have

reply via email to

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