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: Paolo Bonzini
Subject: Re: [RFA] Fix glr.c's YYDEBUG and YY_ERROR_VERBOSE vs. glr.cc
Date: Wed, 13 Sep 2006 09:14:48 +0200
User-agent: Thunderbird 1.5.0.5 (Macintosh/20060719)


For now, I installed this:
Thanks, here's the dozen lines that fix YYDEBUG, without the quite obvious bug you detected. I'm using a member to return a meaningful value from get_debug_level.

I include the enabling of the commented C++ GLR tests, which compile thanks to this, and pass thanks to your installed YY_ERROR_VERBOSE change.

By the way, I confirm that a Java calculator works with your version of the b4_case changes.

Paolo
2006-09-13  Paolo Bonzini  <address@hidden>

        * tests/calc.at (GLR C++ tests): Enable all tests.
        * data/glr.cc (yydebug_): New member.  Initialize in the constructor.
        (get_debug_level): Always compile, return yydebug_.
        (set_debug_level): Always compile, set yydebug only if YYDEBUG,
        set yydebug_ too.

Index: tests/calc.at
===================================================================
RCS file: /sources/bison/bison/tests/calc.at,v
retrieving revision 1.90
diff -u -p -r1.90 calc.at
--- tests/calc.at       8 Jul 2006 20:38:14 -0000       1.90
+++ tests/calc.at       13 Sep 2006 07:05:59 -0000
@@ -642,11 +642,11 @@
 m4_define([AT_CHECK_CALC_GLR_CC],
 [AT_CHECK_CALC([%skeleton "glr.cc" %defines %locations] $@)])
 
-#AT_CHECK_CALC_GLR_CC([])
-#AT_CHECK_CALC_GLR_CC([%error-verbose %name-prefix="calc" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([])
+AT_CHECK_CALC_GLR_CC([%error-verbose %name-prefix="calc" %verbose %yacc])
 
-# AT_CHECK_CALC_GLR_CC([%debug])
-#AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix="calc" %verbose 
%yacc])
+AT_CHECK_CALC_GLR_CC([%debug])
+AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix="calc" %verbose 
%yacc])
 
 AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix="calc" 
%verbose %yacc])
 
Index: data/glr.cc
===================================================================
RCS file: /sources/bison/bison/data/glr.cc,v
retrieving revision 1.26
diff -u -p -r1.26 glr.cc
--- data/glr.cc 12 Sep 2006 17:46:34 -0000      1.26
+++ data/glr.cc 13 Sep 2006 07:05:59 -0000
@@ -123,7 +123,7 @@ namespace ]b4_namespace[
 m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
 [  /// Build a parser object.
   ]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)
-    : yycdebug_ (&std::cerr)]b4_parse_param_cons[
+    : yydebug_ (0), yycdebug_ (&std::cerr)]b4_parse_param_cons[
   {
   }
 
@@ -168,6 +168,7 @@ m4_pushdef([b4_parse_param], m4_defn([b4
     yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
     *yycdebug_ << ')';
   }
+#endif /* ! YYDEBUG */
 
   std::ostream&
   ]b4_parser_class_name[::debug_stream () const
@@ -185,16 +186,18 @@ m4_pushdef([b4_parse_param], m4_defn([b4
   ]b4_parser_class_name[::debug_level_type
   ]b4_parser_class_name[::debug_level () const
   {
-    return ::yydebug;
+    return yydebug_;
   }
 
   void
   ]b4_parser_class_name[::set_debug_level (debug_level_type l)
   {
+    yydebug_ = l;
+#if YYDEBUG
     ::yydebug = l;
+#endif
   }
 
-#endif /* ! YYDEBUG */
 ]m4_popdef([b4_parse_param])dnl
 [} // namespace ]b4_namespace[
 
@@ -352,6 +355,7 @@ b4_user_stype
 
     /* Debugging.  */
     std::ostream* yycdebug_;
+    int yydebug_;
 ]b4_parse_param_vars[
   };
 

reply via email to

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