mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 02:03:03 +00:00
* data/bison.c++: Use C++ ostreams.
(cdebug_): New member.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
2002-05-28 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* data/bison.c++: Use C++ ostreams.
|
||||||
|
(cdebug_): New member.
|
||||||
|
|
||||||
2002-05-28 Akim Demaille <akim@epita.fr>
|
2002-05-28 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/output.c (output_skeleton): Be sure to allocate enough room
|
* src/output.c (output_skeleton): Be sure to allocate enough room
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ b4_copyright
|
|||||||
#include "location.hh"
|
#include "location.hh"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
/* Using locations. */
|
/* Using locations. */
|
||||||
#define YYLSP_NEEDED b4_locations_flag
|
#define YYLSP_NEEDED b4_locations_flag
|
||||||
@@ -228,10 +229,12 @@ namespace yy
|
|||||||
b4_name (bool debug,
|
b4_name (bool debug,
|
||||||
LocationType initlocation[]b4_param) :
|
LocationType initlocation[]b4_param) :
|
||||||
b4_constructor[]debug_ (debug),
|
b4_constructor[]debug_ (debug),
|
||||||
|
cdebug_ (std::cerr),
|
||||||
initlocation_ (initlocation)
|
initlocation_ (initlocation)
|
||||||
#else
|
#else
|
||||||
b4_name (bool debug[]b4_param) :
|
b4_name (bool debug[]b4_param) :
|
||||||
b4_constructor[]debug_ (debug)
|
b4_constructor[]debug_ (debug),
|
||||||
|
cdebug_ (std::cerr)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -297,9 +300,12 @@ namespace yy
|
|||||||
/* State. */
|
/* State. */
|
||||||
int n_;
|
int n_;
|
||||||
int len_;
|
int len_;
|
||||||
int debug_;
|
|
||||||
int state_;
|
int state_;
|
||||||
|
|
||||||
|
/* Debugging. */
|
||||||
|
int debug_;
|
||||||
|
std::ostream &cdebug_;
|
||||||
|
|
||||||
/* Lookahead and lookahead in internal form. */
|
/* Lookahead and lookahead in internal form. */
|
||||||
int looka_;
|
int looka_;
|
||||||
int ilooka_;
|
int ilooka_;
|
||||||
@@ -329,15 +335,9 @@ b4_copyright
|
|||||||
|
|
||||||
/* Enable debugging if requested. */
|
/* Enable debugging if requested. */
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
# include <cstdio>
|
# define YYCDEBUG if (debug_) cdebug_
|
||||||
# define YYFPRINTF std::fprintf
|
|
||||||
# define YYDPRINTF(Args) \
|
|
||||||
do { \
|
|
||||||
if (debug_) \
|
|
||||||
YYFPRINTF Args; \
|
|
||||||
} while (0)
|
|
||||||
#else /* !YYDEBUG */
|
#else /* !YYDEBUG */
|
||||||
# define YYDPRINTF(Args)
|
# define YYCDEBUG if (0) cdebug_
|
||||||
#endif /* !YYDEBUG */
|
#endif /* !YYDEBUG */
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -357,12 +357,12 @@ yy::b4_name::parse ()
|
|||||||
#if YYLSP_NEEDED
|
#if YYLSP_NEEDED
|
||||||
location = initlocation_;
|
location = initlocation_;
|
||||||
#endif
|
#endif
|
||||||
YYDPRINTF ((stderr, "Starting parse\n"));
|
YYCDEBUG << "Starting parse" << std::endl;
|
||||||
|
|
||||||
/* New state. */
|
/* New state. */
|
||||||
yynewstate:
|
yynewstate:
|
||||||
state_stack_.push (state_);
|
state_stack_.push (state_);
|
||||||
YYDPRINTF ((stderr, "Entering state %d\n", state_));
|
YYCDEBUG << "Entering state " << state_ << std::endl;
|
||||||
goto yybackup;
|
goto yybackup;
|
||||||
|
|
||||||
/* Backup. */
|
/* Backup. */
|
||||||
@@ -376,7 +376,7 @@ yy::b4_name::parse ()
|
|||||||
/* Read a lookahead token. */
|
/* Read a lookahead token. */
|
||||||
if (looka_ == empty_)
|
if (looka_ == empty_)
|
||||||
{
|
{
|
||||||
YYDPRINTF ((stderr, "Reading a token: "));
|
YYCDEBUG << "Reading a token: ";
|
||||||
lex_ ();
|
lex_ ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@ yy::b4_name::parse ()
|
|||||||
{
|
{
|
||||||
looka_ = eof_;
|
looka_ = eof_;
|
||||||
ilooka_ = 0;
|
ilooka_ = 0;
|
||||||
YYDPRINTF ((stderr, "Now at end of input.\n"));
|
YYCDEBUG << "Now at end of input." << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -393,9 +393,10 @@ yy::b4_name::parse ()
|
|||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
if (debug_)
|
if (debug_)
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, "Next token is %d (%s", looka_, name_[[ilooka_]]);
|
YYCDEBUG << "Next token is " << looka_
|
||||||
|
<< " (" << name_[[ilooka_]];
|
||||||
print_ ();
|
print_ ();
|
||||||
YYFPRINTF (stderr, ")\n");
|
YYCDEBUG << ')' << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -424,7 +425,8 @@ yy::b4_name::parse ()
|
|||||||
goto yyacceptlab;
|
goto yyacceptlab;
|
||||||
|
|
||||||
/* Shift the lookahead token. */
|
/* Shift the lookahead token. */
|
||||||
YYDPRINTF ((stderr, "Shifting token %d (%s), ", looka_, name_[[ilooka_]]));
|
YYCDEBUG << "Shifting token " << looka_
|
||||||
|
<< " (" << name_[[ilooka_]] << "), ";
|
||||||
|
|
||||||
/* Discard the token being shifted unless it is eof. */
|
/* Discard the token being shifted unless it is eof. */
|
||||||
if (looka_ != eof_)
|
if (looka_ != eof_)
|
||||||
@@ -465,11 +467,12 @@ yy::b4_name::parse ()
|
|||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
if (debug_)
|
if (debug_)
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", n_ - 1, rline_[[n_]]);
|
YYCDEBUG << "Reducing via rule " << n_ - 1
|
||||||
|
<< " (line " << rline_[[n_]] << "), ";
|
||||||
for (b4_uint_type(b4_prhs_max) i = prhs_[[n_]];
|
for (b4_uint_type(b4_prhs_max) i = prhs_[[n_]];
|
||||||
rhs_[[i]] >= 0; ++i)
|
rhs_[[i]] >= 0; ++i)
|
||||||
YYFPRINTF (stderr, "%s ", name_[[rhs_[i]]]);
|
YYCDEBUG << name_[[rhs_[i]]] << ' ';
|
||||||
YYFPRINTF (stderr, "-> %s\n", name_[[r1_[n_]]]);
|
YYCDEBUG << "-> " << name_[[r1_[n_]]] << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -494,11 +497,11 @@ yy::b4_name::parse ()
|
|||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
if (debug_)
|
if (debug_)
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, "state stack now");
|
YYCDEBUG << "state stack now";
|
||||||
for (StateStack::ConstIterator i = state_stack_.begin ();
|
for (StateStack::ConstIterator i = state_stack_.begin ();
|
||||||
i != state_stack_.end (); ++i)
|
i != state_stack_.end (); ++i)
|
||||||
YYFPRINTF (stderr, " %d", *i);
|
YYCDEBUG << ' ' << *i;
|
||||||
YYFPRINTF (stderr, "\n");
|
YYCDEBUG << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -561,7 +564,8 @@ yy::b4_name::parse ()
|
|||||||
/* Return failure if at end of input. */
|
/* Return failure if at end of input. */
|
||||||
if (looka_ == eof_)
|
if (looka_ == eof_)
|
||||||
goto yyabortlab;
|
goto yyabortlab;
|
||||||
YYDPRINTF ((stderr, "Discarding token %d (%s).\n", looka_, name_[[ilooka_]]));
|
YYCDEBUG << "Discarding token " << looka_
|
||||||
|
<< " (" << name_[[ilooka_]] << ")." << std::endl;
|
||||||
looka_ = empty_;
|
looka_ = empty_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,19 +597,19 @@ yy::b4_name::parse ()
|
|||||||
{
|
{
|
||||||
if (stos_[[state_]] < ntokens_)
|
if (stos_[[state_]] < ntokens_)
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, "Error: popping token %d (%s",
|
YYCDEBUG << "Error: popping token "
|
||||||
token_number_[[stos_[state_]]],
|
<< token_number_[[stos_[state_]]]
|
||||||
name_[[stos_[state_]]]);
|
<< " (" << name_[[stos_[state_]]];
|
||||||
# ifdef YYPRINT
|
# ifdef YYPRINT
|
||||||
YYPRINT (stderr, token_number_[[stos_[state_]]],
|
YYPRINT (stderr, token_number_[[stos_[state_]]],
|
||||||
semantic_stack_.top ());
|
semantic_stack_.top ());
|
||||||
# endif
|
# endif
|
||||||
YYFPRINTF (stderr, ")\n");
|
YYCDEBUG << ')' << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, "Error: popping nonterminal (%s)\n",
|
YYCDEBUG << "Error: popping nonterminal ("
|
||||||
name_[[stos_[state_]]]);
|
<< name_[[stos_[state_]]] << ')' << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -617,11 +621,11 @@ yy::b4_name::parse ()
|
|||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
if (debug_)
|
if (debug_)
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, "Error: state stack now");
|
YYCDEBUG << "Error: state stack now";
|
||||||
for (StateStack::ConstIterator i = state_stack_.begin ();
|
for (StateStack::ConstIterator i = state_stack_.begin ();
|
||||||
i != state_stack_.end (); ++i)
|
i != state_stack_.end (); ++i)
|
||||||
YYFPRINTF (stderr, " %d", *i);
|
YYCDEBUG << ' ' << *i;
|
||||||
YYFPRINTF (stderr, "\n");
|
YYCDEBUG << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -629,7 +633,7 @@ yy::b4_name::parse ()
|
|||||||
if (n_ == final_)
|
if (n_ == final_)
|
||||||
goto yyacceptlab;
|
goto yyacceptlab;
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Shifting error token, "));
|
YYCDEBUG << "Shifting error token, ";
|
||||||
|
|
||||||
semantic_stack_.push (value);
|
semantic_stack_.push (value);
|
||||||
location_stack_.push (location);
|
location_stack_.push (location);
|
||||||
|
|||||||
Reference in New Issue
Block a user