%printer: support both yyo and yyoutput.

lalr1.cc used to support yyo, but not yyoutput.  Support both,
but document only yyoutput (at least until there is some consensus
on this).

* data/c.m4 (yy_symbol_value_print): Also support yyo.
* data/glr.cc  (yy_symbol_value_print_): Support both yyo and yyoutput.
* data/lalr1.cc: Also support yyoutput.
* doc/bison.texinfo: Explicitly use yyoutput in the examples.
* examples/mfcalc/mfcalc.test: Test the -p option.
(cherry picked from commit c50263271d)

Conflicts:

	data/c.m4
	data/lalr1.cc
	doc/bison.texinfo
	etc/Makefile.am
This commit is contained in:
Akim Demaille
2012-04-16 17:03:19 +02:00
parent 56d60c1947
commit 68fff38a09
4 changed files with 13 additions and 6 deletions

View File

@@ -456,6 +456,8 @@ m4_define_default([b4_yy_symbol_print_generate],
b4_locations_if([, [[YYLTYPE const * const yylocationp], [yylocationp]]])[]dnl
m4_ifset([b4_parse_param], [, b4_parse_param]))[
{
FILE *yyo = yyoutput;
YYUSE (yyo);
if (!yyvaluep)
return;
]b4_locations_if([ YYUSE (yylocationp);

View File

@@ -151,9 +151,11 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
]b4_parser_class_name[::yy_symbol_value_print_ (int yytype,
const semantic_type* yyvaluep, const location_type* yylocationp)
{
/* Pacify ``unused variable'' warnings. */
YYUSE (yyvaluep);
YYUSE (yylocationp);
YYUSE (yyvaluep);
std::ostream& yyoutput = debug_stream ();
std::ostream& yyo = yyoutput;
YYUSE (yyo);
switch (yytype)
{
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl

View File

@@ -446,6 +446,9 @@ do { \
{
YYUSE (yylocationp);
YYUSE (yyvaluep);
std::ostream& yyo = debug_stream ();
std::ostream& yyoutput = yyo;
YYUSE (yyoutput);
switch (yytype)
{
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl

View File

@@ -3079,14 +3079,14 @@ type:
%code requires @{ #include "type1.h" @}
%union @{ type1 field1; @}
%destructor @{ type1_free ($$); @} <field1>
%printer @{ type1_print ($$); @} <field1>
%printer @{ type1_print (yyoutput, $$); @} <field1>
@end group
@group
%code requires @{ #include "type2.h" @}
%union @{ type2 field2; @}
%destructor @{ type2_free ($$); @} <field2>
%printer @{ type2_print ($$); @} <field2>
%printer @{ type2_print (yyoutput, $$); @} <field2>
@end group
@end example
@@ -9665,10 +9665,10 @@ To enable memory deallocation during error recovery, use
@c FIXME: Document %printer, and mention that it takes a braced-code operand.
@comment file: calc++-parser.yy
@example
%printer @{ debug_stream () << *$$; @} "identifier"
%printer @{ yyoutput << *$$; @} "identifier"
%destructor @{ delete $$; @} "identifier"
%printer @{ debug_stream () << $$; @} <ival>
%printer @{ yyoutput << $$; @} <ival>
@end example
@noindent