]> git.saurik.com Git - bison.git/commitdiff
Simplify the C++ parser constructor.
authorAkim Demaille <akim@epita.fr>
Wed, 15 Dec 2004 16:18:12 +0000 (16:18 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 15 Dec 2004 16:18:12 +0000 (16:18 +0000)
* data/lalr1.cc (debug_): Rename as...
(yydebug_): so that the parser's internals are always in the yy*
pseudo namespace.
Adjust uses.
(b4_parse_param_decl): Remove the leading comma as it is now only
called as unique argument list.
(Parser::Parser): Remove the constructor accepting a location and
an initial debugging level.
Remove from the other ctor the argument for the debugging level.
(debug_level_type, debug_level, set_debug_level): New.
* tests/actions.at, tests/calc.at, tests/regression.at: Adjust
constructor calls.

ChangeLog
data/lalr1.cc
tests/actions.at
tests/calc.at
tests/regression.at

index f6835dbfd6accba2b31af50b2b35351d8279b8a9..43cdc0085446611f00d3c7631cde68503e448ef6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,25 @@
+2004-12-15  Akim Demaille  <akim@epita.fr>
+
+       Simplify the C++ parser constructor.
+
+       * data/lalr1.cc (debug_): Rename as...
+       (yydebug_): so that the parser's internals are always in the yy*
+       pseudo namespace.
+       Adjust uses.
+       (b4_parse_param_decl): Remove the leading comma as it is now only
+       called as unique argument list.
+       (Parser::Parser): Remove the constructor accepting a location and
+       an initial debugging level.
+       Remove from the other ctor the argument for the debugging level.
+       (debug_level_type, debug_level, set_debug_level): New.
+
+       * tests/actions.at, tests/calc.at, tests/regression.at: Adjust
+       constructor calls.
+
 2004-12-15  Akim Demaille  <akim@epita.fr>
 
        Remove b4_root related material: failure experiment
-       (which goal was to allow to derive from an class).
+       (which goal was to allow to derive from a class).
 
        * data/lalr1.cc (b4_root, b4_param, b4_constructor): Remove
        definitions and uses.
index a68eecc34ce004dc0f4010bc9a136995aae62f2f..0ba7720d8e927dde460a95a2fead71521d318d7a 100644 (file)
@@ -70,7 +70,7 @@ m4_define([b4_rhs_location],
 # argument name in the constructor.
 m4_define([b4_parse_param_decl],
 [m4_ifset([b4_parse_param],
-          [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
+          [m4_map_sep([b4_parse_param_decl_1], [, ], [b4_parse_param])])])
 
 m4_define([b4_parse_param_decl_1],
 [$1_yyarg])
@@ -217,23 +217,12 @@ namespace yy
     typedef Stack<SemanticType> SemanticStack;
     typedef Stack<LocationType> LocationStack;
 
-    ]b4_parser_class_name[ (bool debug]b4_parse_param_decl[) :
-      debug_ (debug),
+    ]b4_parser_class_name[ (]b4_parse_param_decl[) :
+      yydebug_ (false),
       yycdebug_ (&std::cerr)]b4_parse_param_cons[
     {
     }
 
-    ]b4_parser_class_name[ (bool debug,
-           LocationType]b4_parse_param_decl[) :
-      debug_ (debug),
-      yycdebug_ (&std::cerr)]b4_parse_param_cons[
-    {
-      *yycdebug_ << __FILE__ << ':' << __LINE__
-                << ": this constructor is provided by backward compatibility"
-                << ", but will be removed in the near future."
-                << std::endl;
-    }
-
     virtual ~]b4_parser_class_name[ ()
     {
     }
@@ -245,6 +234,13 @@ namespace yy
     /// Set the current debugging stream.
     void set_debug_stream (std::ostream &);
 
+    /// Type for debugging levels.
+    typedef int debug_level_type;
+    /// The current debugging level.
+    debug_level_type debug_level () const;
+    /// Set the current debugging level.
+    void set_debug_level (debug_level_type l);
+
   private:
 
     virtual void lex_ ();
@@ -321,7 +317,7 @@ namespace yy
     int errstatus_;
 
     /* Debugging.  */
-    int debug_;
+    int yydebug_;
     std::ostream* yycdebug_;
 
     /* Look-ahead and look-ahead in internal form.  */
@@ -354,9 +350,9 @@ b4_copyright([C++ Skeleton parser for LALR(1) parsing with Bison],
 
 m4_if(b4_defines_flag, 0, [], [#include @output_header_name@])[
 
-/* A pseudo ostream that takes debug_ into account. */
+/* A pseudo ostream that takes yydebug_ into account. */
 # define YYCDEBUG                                                      \
-  for (bool yydebugcond_ = debug_; yydebugcond_; yydebugcond_ = false) \
+  for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false)       \
     (*yycdebug_)
 
 /* Enable debugging if requested.  */
@@ -364,7 +360,7 @@ m4_if(b4_defines_flag, 0, [], [#include @output_header_name@])[
 
 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
 do {                                                   \
-  if (debug_)                                          \
+  if (yydebug_)                                                \
     {                                                  \
       *yycdebug_ << (Title) << ' ';                    \
       symprint_ ((Type), (Value), (Location));         \
@@ -374,13 +370,13 @@ do {                                                      \
 
 # define YY_REDUCE_PRINT(Rule)         \
 do {                                   \
-  if (debug_)                          \
+  if (yydebug_)                                \
     reduce_print_ (Rule);              \
 } while (0)
 
 # define YY_STACK_PRINT()              \
 do {                                   \
-  if (debug_)                          \
+  if (yydebug_)                                \
     stack_print_ ();                   \
 } while (0)
 
@@ -464,6 +460,19 @@ yy::]b4_parser_class_name[::set_debug_stream (std::ostream& o)
 }
 
 
+yy::]b4_parser_class_name[::debug_level_type
+yy::]b4_parser_class_name[::debug_level () const
+{
+  return yydebug_;
+}
+
+void
+yy::]b4_parser_class_name[::set_debug_level (debug_level_type l)
+{
+  yydebug_ = l;
+}
+
+
 int
 yy::]b4_parser_class_name[::parse ()
 {
index 15f25c03489fe93e78e227538e487c8e27887be1..fa779b39145d0a4c7f41af7cc2e40200c575f744 100644 (file)
@@ -320,7 +320,8 @@ static bool yydebug;
 int
 yyparse ()
 {
-  yy::Parser parser (yydebug);
+  yy::Parser parser;
+  parser.set_debug_level (yydebug);
   return parser.parse ();
 }
 ],
index 83ce28314b32363aa3a79f5e2c09a78d33770b4d..27598e613ecf3235425e5938b0b745cec2848e42 100644 (file)
@@ -136,7 +136,8 @@ yy::Parser::error_ ()
 int
 yyparse (AT_PARAM_IF([semantic_value *result, int *count]))
 {
-  yy::Parser parser (!!YYDEBUG[]AT_PARAM_IF([, result, count]));
+  yy::Parser parser[]AT_PARAM_IF([ (result, count)]);
+  parser.set_debug_level (!!YYDEBUG);
   return parser.parse ();
 }
 ],
index c199ecc112ecbfa656c7e84fbb6c5061d1df34b4..ab0b71e8ac57fa81508a13c81413b9876d59d7a4 100644 (file)
@@ -735,7 +735,8 @@ yy::Parser::error_ ()
 int
 yyparse (void)
 {
-  yy::Parser parser (!!YYDEBUG);
+  yy::Parser parser;
+  parser.set_debug_level (!!YYDEBUG);
   return parser.parse ();
 }
 ],