mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 09:13:04 +00:00
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.
This commit is contained in:
20
ChangeLog
20
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>
|
2004-12-15 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
Remove b4_root related material: failure experiment
|
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
|
* data/lalr1.cc (b4_root, b4_param, b4_constructor): Remove
|
||||||
definitions and uses.
|
definitions and uses.
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ m4_define([b4_rhs_location],
|
|||||||
# argument name in the constructor.
|
# argument name in the constructor.
|
||||||
m4_define([b4_parse_param_decl],
|
m4_define([b4_parse_param_decl],
|
||||||
[m4_ifset([b4_parse_param],
|
[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],
|
m4_define([b4_parse_param_decl_1],
|
||||||
[$1_yyarg])
|
[$1_yyarg])
|
||||||
@@ -217,23 +217,12 @@ namespace yy
|
|||||||
typedef Stack<SemanticType> SemanticStack;
|
typedef Stack<SemanticType> SemanticStack;
|
||||||
typedef Stack<LocationType> LocationStack;
|
typedef Stack<LocationType> LocationStack;
|
||||||
|
|
||||||
]b4_parser_class_name[ (bool debug]b4_parse_param_decl[) :
|
]b4_parser_class_name[ (]b4_parse_param_decl[) :
|
||||||
debug_ (debug),
|
yydebug_ (false),
|
||||||
yycdebug_ (&std::cerr)]b4_parse_param_cons[
|
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[ ()
|
virtual ~]b4_parser_class_name[ ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -245,6 +234,13 @@ namespace yy
|
|||||||
/// Set the current debugging stream.
|
/// Set the current debugging stream.
|
||||||
void set_debug_stream (std::ostream &);
|
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:
|
private:
|
||||||
|
|
||||||
virtual void lex_ ();
|
virtual void lex_ ();
|
||||||
@@ -321,7 +317,7 @@ namespace yy
|
|||||||
int errstatus_;
|
int errstatus_;
|
||||||
|
|
||||||
/* Debugging. */
|
/* Debugging. */
|
||||||
int debug_;
|
int yydebug_;
|
||||||
std::ostream* yycdebug_;
|
std::ostream* yycdebug_;
|
||||||
|
|
||||||
/* Look-ahead and look-ahead in internal form. */
|
/* 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@])[
|
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 \
|
# define YYCDEBUG \
|
||||||
for (bool yydebugcond_ = debug_; yydebugcond_; yydebugcond_ = false) \
|
for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \
|
||||||
(*yycdebug_)
|
(*yycdebug_)
|
||||||
|
|
||||||
/* Enable debugging if requested. */
|
/* 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) \
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||||
do { \
|
do { \
|
||||||
if (debug_) \
|
if (yydebug_) \
|
||||||
{ \
|
{ \
|
||||||
*yycdebug_ << (Title) << ' '; \
|
*yycdebug_ << (Title) << ' '; \
|
||||||
symprint_ ((Type), (Value), (Location)); \
|
symprint_ ((Type), (Value), (Location)); \
|
||||||
@@ -374,13 +370,13 @@ do { \
|
|||||||
|
|
||||||
# define YY_REDUCE_PRINT(Rule) \
|
# define YY_REDUCE_PRINT(Rule) \
|
||||||
do { \
|
do { \
|
||||||
if (debug_) \
|
if (yydebug_) \
|
||||||
reduce_print_ (Rule); \
|
reduce_print_ (Rule); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
# define YY_STACK_PRINT() \
|
# define YY_STACK_PRINT() \
|
||||||
do { \
|
do { \
|
||||||
if (debug_) \
|
if (yydebug_) \
|
||||||
stack_print_ (); \
|
stack_print_ (); \
|
||||||
} while (0)
|
} 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
|
int
|
||||||
yy::]b4_parser_class_name[::parse ()
|
yy::]b4_parser_class_name[::parse ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -320,7 +320,8 @@ static bool yydebug;
|
|||||||
int
|
int
|
||||||
yyparse ()
|
yyparse ()
|
||||||
{
|
{
|
||||||
yy::Parser parser (yydebug);
|
yy::Parser parser;
|
||||||
|
parser.set_debug_level (yydebug);
|
||||||
return parser.parse ();
|
return parser.parse ();
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -136,7 +136,8 @@ yy::Parser::error_ ()
|
|||||||
int
|
int
|
||||||
yyparse (AT_PARAM_IF([semantic_value *result, int *count]))
|
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 ();
|
return parser.parse ();
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -735,7 +735,8 @@ yy::Parser::error_ ()
|
|||||||
int
|
int
|
||||||
yyparse (void)
|
yyparse (void)
|
||||||
{
|
{
|
||||||
yy::Parser parser (!!YYDEBUG);
|
yy::Parser parser;
|
||||||
|
parser.set_debug_level (!!YYDEBUG);
|
||||||
return parser.parse ();
|
return parser.parse ();
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user