bison-patches
[Top][All Lists]
Advanced

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

Re: [RFA] Fix glr.c's YYDEBUG and YY_ERROR_VERBOSE vs. glr.cc


From: Paul Eggert
Subject: Re: [RFA] Fix glr.c's YYDEBUG and YY_ERROR_VERBOSE vs. glr.cc
Date: Tue, 12 Sep 2006 10:54:30 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Paolo Bonzini <address@hidden> writes:

>> This can be considered a bug in glr.c actually,

More accurately, it's a documented misfeature:

   @deffn {Macro} YYERROR_VERBOSE
   An obsolete macro that you define with @code{#define} in the prologue
   to request verbose, specific error message strings
   when @code{yyerror} is called.  It doesn't matter what definition you
   use for @code{YYERROR_VERBOSE}, just whether you define it.  Using
   @code{%error-verbose} is preferred.

and we don't want to change its semantics now.  With that in mind,
isn't the real bug here that glr.cc is defining a macro that it
shouldn't be messing with?  And similarly for YYTOKEN_TABLE.

>> Second, yy::parser::set_debug_level is never defined unless %debug
>> is specified.  This because it just sets "::yydebug" to its
>> argument, and the variable is not defined in glr.c unless YYDEBUG is
>> defined.  This patch also fixes it by making the function do nothing
>> unless %debug is specified.

But that patch causes ::debug_level to return garbage.  Surely
that isn't intended.

If the intent here is to remove the reliance of C++ code on namespace
horrors like YYDEBUG, I can understand that, but I suspect this needs
to be addressed more systematically in all the C++ code, and handled
the usual way that C++ guys do these sorts of things (what do they use
instead of <assert.h>, for example?), and documented, and so forth.
(I don't use C++ so I'm probably not the best guy to ask here....)

For now, I installed this:

2006-09-12  Paul Eggert  <address@hidden>

        * data/glr.cc (YYERROR_VERBOSE, YYTOKEN_TABLE): Remove.
        We don't need them in glr.cc, and glr.c defines them.
        Defining YYERROR_VERBOSE to 0 here breaks glr.c, since glr.c
        assumes that defining it to anything is the same as defining
        it to 1.  Problem reported by Paolo Bonzini.

--- data/glr.cc 11 Sep 2006 18:56:58 -0000      1.25
+++ data/glr.cc 12 Sep 2006 17:45:48 -0000
@@ -244,19 +244,6 @@ namespace ]b4_namespace[
 # define YYDEBUG ]b4_debug_flag[
 #endif
 
-/* Enabling verbose error messages.  */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE ]b4_error_verbose_flag[
-#endif
-
-/* Enabling the token table.  */
-#ifndef YYTOKEN_TABLE
-# define YYTOKEN_TABLE ]b4_token_table[
-#endif
-
 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
    If N is 0, then set CURRENT to the empty location which ends
    the previous symbol: RHS[0] (always defined).  */




reply via email to

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