[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: lalr1.cc: set_debug_level
From: |
Akim Demaille |
Subject: |
FYI: lalr1.cc: set_debug_level |
Date: |
Wed, 15 Dec 2004 17:13:24 +0100 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux) |
Index: ChangeLog
from Akim Demaille <address@hidden>
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.
Index: data/lalr1.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
retrieving revision 1.66
diff -u -u -r1.66 lalr1.cc
--- data/lalr1.cc 15 Dec 2004 15:35:17 -0000 1.66
+++ data/lalr1.cc 15 Dec 2004 16:16:22 -0000
@@ -70,7 +70,7 @@
# 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 @@
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 @@
/// 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 @@
int errstatus_;
/* Debugging. */
- int debug_;
+ int yydebug_;
std::ostream* yycdebug_;
/* Look-ahead and look-ahead in internal form. */
@@ -354,9 +350,9 @@
m4_if(b4_defines_flag, 0, [], [#include @address@hidden)[
-/* 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 @@
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
- if (debug_) \
+ if (yydebug_) \
{ \
*yycdebug_ << (Title) << ' '; \
symprint_ ((Type), (Value), (Location)); \
@@ -374,13 +370,13 @@
# 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[::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: tests/actions.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/actions.at,v
retrieving revision 1.43
diff -u -u -r1.43 actions.at
--- tests/actions.at 11 Dec 2004 07:07:48 -0000 1.43
+++ tests/actions.at 15 Dec 2004 16:16:22 -0000
@@ -320,7 +320,8 @@
int
yyparse ()
{
- yy::Parser parser (yydebug);
+ yy::Parser parser;
+ parser.set_debug_level (yydebug);
return parser.parse ();
}
],
Index: tests/calc.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/calc.at,v
retrieving revision 1.67
diff -u -u -r1.67 calc.at
--- tests/calc.at 17 Nov 2004 14:19:37 -0000 1.67
+++ tests/calc.at 15 Dec 2004 16:16:22 -0000
@@ -136,7 +136,8 @@
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: tests/regression.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/regression.at,v
retrieving revision 1.84
diff -u -u -r1.84 regression.at
--- tests/regression.at 17 Nov 2004 14:19:37 -0000 1.84
+++ tests/regression.at 15 Dec 2004 16:16:22 -0000
@@ -735,7 +735,8 @@
int
yyparse (void)
{
- yy::Parser parser (!!YYDEBUG);
+ yy::Parser parser;
+ parser.set_debug_level (!!YYDEBUG);
return parser.parse ();
}
],
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: lalr1.cc: set_debug_level,
Akim Demaille <=