style: don't use std::endl

* data/lalr1.cc, doc/bison.texi, etc/bench.pl.in, examples/variant.yy,
* tests/actions.at, tests/atlocal.in, tests/c++.at, tests/headers.at,
* tests/local.at, tests/types.at:
Don't use std::endl, it flushes uselessly, and is considered bad
style.
This commit is contained in:
Akim Demaille
2018-05-08 12:15:55 +02:00
parent ad9500f3fd
commit dbd1609311
10 changed files with 32 additions and 33 deletions

View File

@@ -443,7 +443,7 @@ m4_if(b4_prefix, [yy], [],
{ \ { \
*yycdebug_ << Title << ' '; \ *yycdebug_ << Title << ' '; \
yy_print_ (*yycdebug_, Symbol); \ yy_print_ (*yycdebug_, Symbol); \
*yycdebug_ << std::endl; \ *yycdebug_ << '\n'; \
} \ } \
} while (false) } while (false)
@@ -736,7 +736,7 @@ m4_if(b4_prefix, [yy], [],
// avoid gratuitous conflicts when merging into the master branch. // avoid gratuitous conflicts when merging into the master branch.
try try
{ {
YYCDEBUG << "Starting parse" << std::endl; YYCDEBUG << "Starting parse\n";
]m4_ifdef([b4_initial_action], [ ]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl
@@ -753,7 +753,7 @@ b4_dollar_popdef])[]dnl
// A new symbol was pushed on the stack. // A new symbol was pushed on the stack.
yynewstate: yynewstate:
YYCDEBUG << "Entering state " << yystack_[0].state << std::endl; YYCDEBUG << "Entering state " << yystack_[0].state << '\n';
// Accept? // Accept?
if (yystack_[0].state == yyfinal_) if (yystack_[0].state == yyfinal_)
@@ -993,8 +993,7 @@ b4_dollar_popdef])[]dnl
} }
catch (...) catch (...)
{ {
YYCDEBUG << "Exception caught: cleaning lookahead and stack" YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
<< std::endl;
// Do not try to display the values of the reclaimed symbols, // Do not try to display the values of the reclaimed symbols,
// as their printer might throw an exception. // as their printer might throw an exception.
if (!yyla.empty ()) if (!yyla.empty ())
@@ -1144,7 +1143,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
i_end = yystack_.end (); i_end = yystack_.end ();
i != i_end; ++i) i != i_end; ++i)
*yycdebug_ << ' ' << i->state; *yycdebug_ << ' ' << i->state;
*yycdebug_ << std::endl; *yycdebug_ << '\n';
} }
// Report on the debug stream that the rule \a yyrule is going to be reduced. // Report on the debug stream that the rule \a yyrule is going to be reduced.
@@ -1155,7 +1154,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
int yynrhs = yyr2_[yyrule]; int yynrhs = yyr2_[yyrule];
// Print the symbols being reduced, and their result. // Print the symbols being reduced, and their result.
*yycdebug_ << "Reducing stack by rule " << yyrule - 1 *yycdebug_ << "Reducing stack by rule " << yyrule - 1
<< " (line " << yylno << "):" << std::endl; << " (line " << yylno << "):\n";
// The symbols being reduced. // The symbols being reduced.
for (int yyi = 0; yyi < yynrhs; yyi++) for (int yyi = 0; yyi < yynrhs; yyi++)
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",

View File

@@ -11174,13 +11174,13 @@ calcxx_driver::parse (const std::string &f)
void void
calcxx_driver::error (const yy::location& l, const std::string& m) calcxx_driver::error (const yy::location& l, const std::string& m)
@{ @{
std::cerr << l << ": " << m << std::endl; std::cerr << l << ": " << m << '\n';
@} @}
void void
calcxx_driver::error (const std::string& m) calcxx_driver::error (const std::string& m)
@{ @{
std::cerr << m << std::endl; std::cerr << m << '\n';
@} @}
@end example @end example
@@ -11533,7 +11533,7 @@ main (int argc, char *argv[])
else if (argv[i] == std::string ("-s")) else if (argv[i] == std::string ("-s"))
driver.trace_scanning = true; driver.trace_scanning = true;
else if (!driver.parse (argv[i])) else if (!driver.parse (argv[i]))
std::cout << driver.result << std::endl; std::cout << driver.result << '\n';
else else
res = 1; res = 1;
return res; return res;

View File

@@ -738,7 +738,7 @@ yy::parser::token_type yylex(yy::parser::semantic_type* yylvalp,
void void
yy::parser::error(const yy::parser::location_type& loc, const std::string& msg) yy::parser::error(const yy::parser::location_type& loc, const std::string& msg)
{ {
std::cerr << loc << ": " << msg << std::endl; std::cerr << loc << ": " << msg << '\n';
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])

View File

@@ -85,7 +85,7 @@ typedef std::list<std::string> strings_type;
%% %%
result: result:
list { std::cout << $1 << std::endl; } list { std::cout << $1 << '\n'; }
; ;
list: list:
@@ -135,7 +135,7 @@ namespace yy
void void
parser::error (const parser::location_type& loc, const std::string& msg) parser::error (const parser::location_type& loc, const std::string& msg)
{ {
std::cerr << loc << ": " << msg << std::endl; std::cerr << loc << ": " << msg << '\n';
} }
} }

View File

@@ -203,7 +203,7 @@ AT_DATA_GRAMMAR([[input.y]],
]AT_YYLEX_DECLARE[ ]AT_YYLEX_DECLARE[
} }
%% %%
exp: { ]AT_SKEL_CC_IF([[std::cerr << @$ << std::endl]], exp: { ]AT_SKEL_CC_IF([[std::cerr << @$ << '\n']],
[[LOCATION_PRINT(stderr, @$); fputc ('\n', stderr)]])[; } [[LOCATION_PRINT(stderr, @$); fputc ('\n', stderr)]])[; }
%% %%
]AT_YYERROR_DEFINE[ ]AT_YYERROR_DEFINE[

View File

@@ -69,7 +69,7 @@ if $BISON_CXX_WORKS; then
int main () int main ()
{ {
std::cout << "Works" << std::endl; std::cout << "Works\n";
} }
EOF EOF
$CXX $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS -o conftest conftest.cc $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS -o conftest conftest.cc

View File

@@ -49,7 +49,7 @@ check (const T& in, const std::string& s)
os << in; os << in;
if (os.str () != s) if (os.str () != s)
{ {
std::cerr << "fail: " << os.str () << ", expected: " << s << std::endl; std::cerr << "fail: " << os.str () << ", expected: " << s << '\n';
return false; return false;
} }
return true; return true;
@@ -140,13 +140,13 @@ int main()
{ {
{ {
yy::parser::symbol_type s = yy::parser::make_INT(12); yy::parser::symbol_type s = yy::parser::make_INT(12);
std::cerr << s.value.as<int>() << std::endl; std::cerr << s.value.as<int>() << '\n';
} }
{ {
yy::parser::symbol_type s = yy::parser::make_INT(123); yy::parser::symbol_type s = yy::parser::make_INT(123);
yy::parser::stack_symbol_type ss(1, s); yy::parser::stack_symbol_type ss(1, s);
std::cerr << ss.value.as<int>() << std::endl; std::cerr << ss.value.as<int>() << '\n';
} }
{ {
@@ -268,7 +268,7 @@ typedef std::vector<std::string> strings_type;
%% %%
result: result:
list { std::cout << $][1 << std::endl; } list { std::cout << $][1 << '\n'; }
; ;
list: list:
@@ -504,7 +504,7 @@ void
]$1[::parser::error (const ]$1[::parser::location_type &loc, ]$1[::parser::error (const ]$1[::parser::location_type &loc,
const std::string &msg) const std::string &msg)
{ {
std::cerr << "At " << loc << ": " << msg << std::endl; std::cerr << "At " << loc << ": " << msg << '\n';
} }
]AT_MAIN_DEFINE[ ]AT_MAIN_DEFINE[
@@ -572,7 +572,7 @@ AT_DATA_GRAMMAR([[input.y]],
%nonassoc 'a' ; %nonassoc 'a' ;
%destructor { %destructor {
std::cerr << "Discarding 'a'." << std::endl; std::cerr << "Discarding 'a'.\n";
} 'a' } 'a'
%% %%
@@ -581,7 +581,7 @@ start: error-reduce consistent-error 'a' { USE ($3); };
error-reduce: error-reduce:
'a' 'a' consistent-error 'a' { USE (($1, $2, $4)); } 'a' 'a' consistent-error 'a' { USE (($1, $2, $4)); }
| 'a' error { std::cerr << "Reducing 'a'." << std::endl; USE ($1); } | 'a' error { std::cerr << "Reducing 'a'.\n"; USE ($1); }
; ;
consistent-error: consistent-error:
@@ -605,7 +605,7 @@ yylex (yy::parser::semantic_type *)
void void
yy::parser::error (const std::string &m) yy::parser::error (const std::string &m)
{ {
std::cerr << m << std::endl; std::cerr << m << '\n';
} }
]AT_MAIN_DEFINE[ ]AT_MAIN_DEFINE[
@@ -651,7 +651,7 @@ start:
; ;
thing: thing:
error { std::cerr << "caught error" << std::endl; } error { std::cerr << "caught error\n"; }
| item | item
; ;
@@ -681,7 +681,7 @@ yylex (yy::parser::semantic_type *)
void void
yy::parser::error (const std::string &m) yy::parser::error (const std::string &m)
{ {
std::cerr << "error: " << m << std::endl; std::cerr << "error: " << m << '\n';
} }
]AT_MAIN_DEFINE[ ]AT_MAIN_DEFINE[
]]) ]])
@@ -797,7 +797,7 @@ $1
std::cerr << sep << *i; std::cerr << sep << *i;
sep = ", "; sep = ", ";
} }
std::cerr << " }" << std::endl; std::cerr << " }\n";
} }
} }
}; };
@@ -929,11 +929,11 @@ main (int argc, const char *argv[])
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
std::cerr << "exception caught: " << e.what () << std::endl; std::cerr << "exception caught: " << e.what () << '\n';
} }
catch (...) catch (...)
{ {
std::cerr << "unknown exception caught" << std::endl; std::cerr << "unknown exception caught\n";
} }
Object::log (YY_NULLPTR, "end"); Object::log (YY_NULLPTR, "end");
assert (Object::empty()); assert (Object::empty());

View File

@@ -181,7 +181,7 @@ extern "C"
do { \ do { \
int res = S; \ int res = S; \
if (res) \ if (res) \
std::cerr << #S": " << res << std::endl; \ std::cerr << #S": " << res << '\n'; \
} while (false) } while (false)
int int

View File

@@ -539,7 +539,7 @@ m4_define([AT_YYERROR_DEFINE(c++)],
void void
]AT_NAME_PREFIX[::parser::error (]AT_LOCATION_IF([[const location_type& l, ]])[const std::string& m) ]AT_NAME_PREFIX[::parser::error (]AT_LOCATION_IF([[const location_type& l, ]])[const std::string& m)
{ {
std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl; std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << '\n';
}]]) }]])
@@ -892,7 +892,7 @@ void foo()
} }
catch (...) catch (...)
{ {
std::cerr << "Inner caught" << std::endl; std::cerr << "Inner caught\n";
throw; throw;
} }
} }
@@ -905,7 +905,7 @@ int main()
} }
catch (...) catch (...)
{ {
std::cerr << "Outer caught" << std::endl; std::cerr << "Outer caught\n";
return 0; return 0;
} }
return 1; return 1;

View File

@@ -243,7 +243,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
%define api.value.type variant], %define api.value.type variant],
[%token <int> '1'; [%token <int> '1';
%token <std::string> '2';], %token <std::string> '2';],
['1' '2' { std::cout << $1 << ", " << $2 << std::endl; }], ['1' '2' { std::cout << $1 << ", " << $2 << '\n'; }],
["12"], ["12"],
[if (res == '1') [if (res == '1')
AT_VAL.build(10); AT_VAL.build(10);