]b4_parser_class_name[ (bool debug][]b4_param[]b4_parse_param_decl[) :
]b4_constructor[][debug_ (debug),
- cdebug_ (std::cerr)]b4_parse_param_cons[
+ yycdebug_ (&std::cerr)]b4_parse_param_cons[
{
}
]b4_parser_class_name[ (bool debug,
LocationType][]b4_param[]b4_parse_param_decl[) :
]b4_constructor[][debug_ (debug),
- cdebug_ (std::cerr)]b4_parse_param_cons[
+ yycdebug_ (&std::cerr)]b4_parse_param_cons[
{
- cdebug_ << __FILE__ << ':' << __LINE__
- << ": this constructor is provided by backward compatibility"
- << ", but will be removed in the near future."
- << std::endl;
+ *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 int parse ();
+ /// Return the current debugging stream.
+ std::ostream& debug_stream () const;
+ /// Set the current debugging stream.
+ void set_debug_stream (std::ostream &);
+
private:
virtual void lex_ ();
/* Debugging. */
int debug_;
- std::ostream& cdebug_;
+ std::ostream* yycdebug_;
/* Look-ahead and look-ahead in internal form. */
int looka_;
m4_if(b4_defines_flag, 0, [], [#include @output_header_name@])[
+/* A pseudo ostream that takes debug_ into account. */
+# define YYCDEBUG \
+ for (bool yydebugcond_ = debug_; yydebugcond_; yydebugcond_ = false) \
+ (*yycdebug_)
+
/* Enable debugging if requested. */
#if YYDEBUG
-# define YYCDEBUG \
- if (debug_) \
- cdebug_
-
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (debug_) \
{ \
- cdebug_ << (Title) << ' '; \
+ *yycdebug_ << (Title) << ' '; \
symprint_ ((Type), (Value), (Location)); \
- cdebug_ << std::endl; \
+ *yycdebug_ << std::endl; \
} \
} while (0)
#else /* !YYDEBUG */
-# define YYCDEBUG if (0) cdebug_
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_REDUCE_PRINT(Rule)
# define YY_STACK_PRINT()
/* Pacify ``unused variable'' warnings. */
(void) yyvaluep;
(void) yylocationp;
+ /* Backward compatibility, but should be removed eventually. */
+ std::ostream& cdebug_ = *yycdebug_;
- cdebug_ << (yytype < ntokens_ ? "token" : "nterm")
- << ' ' << name_[yytype] << " ("
- << *yylocationp << ": ";
+ *yycdebug_ << (yytype < ntokens_ ? "token" : "nterm")
+ << ' ' << name_[yytype] << " ("
+ << *yylocationp << ": ";
switch (yytype)
{
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
[ default:
break;
}
- cdebug_ << ')';
+ *yycdebug_ << ')';
}
#endif /* ! YYDEBUG */
location_stack_.pop (n);
}
+std::ostream&
+yy::]b4_parser_class_name[::debug_stream () const
+{
+ return *yycdebug_;
+}
+
+void
+yy::]b4_parser_class_name[::set_debug_stream (std::ostream& o)
+{
+ yycdebug_ = &o;
+}
+
+
int
yy::]b4_parser_class_name[::parse ()
{
void
yy::]b4_parser_class_name[::stack_print_ ()
{
- cdebug_ << "Stack now";
+ *yycdebug_ << "Stack now";
for (StateStack::const_iterator i = state_stack_.begin ();
i != state_stack_.end (); ++i)
- cdebug_ << ' ' << *i;
- cdebug_ << std::endl;
+ *yycdebug_ << ' ' << *i;
+ *yycdebug_ << std::endl;
}
/** Report that the YYRULE is going to be reduced. */
{
unsigned int yylno = rline_[yyrule];
/* Print the symbols being reduced, and their result. */
- cdebug_ << "Reducing stack by rule " << n_ - 1
- << " (line " << yylno << "), ";
+ *yycdebug_ << "Reducing stack by rule " << n_ - 1
+ << " (line " << yylno << "), ";
for (]b4_int_type_for([b4_prhs])[ i = prhs_[n_];
0 <= rhs_[i]; ++i)
- cdebug_ << name_[rhs_[i]] << ' ';
- cdebug_ << "-> " << name_[r1_[n_]] << std::endl;
+ *yycdebug_ << name_[rhs_[i]] << ' ';
+ *yycdebug_ << "-> " << name_[r1_[n_]] << std::endl;
}
#endif // YYDEBUG