summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2018-05-08 12:15:55 +0200
committerAkim Demaille <akim.demaille@gmail.com>2018-05-08 12:35:06 +0200
commitdbd160931185c25d7f9a3e9c0b5ef64e4deb394f (patch)
treec8e124b754a728396ae2693ed812f9adbf09e9ff
parentad9500f3fdd69d5e8f9d6ca259e01568486cfdf9 (diff)
downloadbison-dbd160931185c25d7f9a3e9c0b5ef64e4deb394f.tar.gz
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.
-rw-r--r--data/lalr1.cc13
-rw-r--r--doc/bison.texi6
-rwxr-xr-xetc/bench.pl.in2
-rw-r--r--examples/variant.yy4
-rw-r--r--tests/actions.at2
-rw-r--r--tests/atlocal.in2
-rw-r--r--tests/c++.at26
-rw-r--r--tests/headers.at2
-rw-r--r--tests/local.at6
-rw-r--r--tests/types.at2
10 files changed, 32 insertions, 33 deletions
diff --git a/data/lalr1.cc b/data/lalr1.cc
index 4c823409..b44a7fd6 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -443,7 +443,7 @@ m4_if(b4_prefix, [yy], [],
{ \
*yycdebug_ << Title << ' '; \
yy_print_ (*yycdebug_, Symbol); \
- *yycdebug_ << std::endl; \
+ *yycdebug_ << '\n'; \
} \
} while (false)
@@ -736,7 +736,7 @@ m4_if(b4_prefix, [yy], [],
// avoid gratuitous conflicts when merging into the master branch.
try
{
- YYCDEBUG << "Starting parse" << std::endl;
+ YYCDEBUG << "Starting parse\n";
]m4_ifdef([b4_initial_action], [
b4_dollar_pushdef([yyla.value], [], [yyla.location])dnl
@@ -753,7 +753,7 @@ b4_dollar_popdef])[]dnl
// A new symbol was pushed on the stack.
yynewstate:
- YYCDEBUG << "Entering state " << yystack_[0].state << std::endl;
+ YYCDEBUG << "Entering state " << yystack_[0].state << '\n';
// Accept?
if (yystack_[0].state == yyfinal_)
@@ -993,8 +993,7 @@ b4_dollar_popdef])[]dnl
}
catch (...)
{
- YYCDEBUG << "Exception caught: cleaning lookahead and stack"
- << std::endl;
+ YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
// Do not try to display the values of the reclaimed symbols,
// as their printer might throw an exception.
if (!yyla.empty ())
@@ -1144,7 +1143,7 @@ b4_error_verbose_if([state_type yystate, const symbol_type& yyla],
i_end = yystack_.end ();
i != i_end; ++i)
*yycdebug_ << ' ' << i->state;
- *yycdebug_ << std::endl;
+ *yycdebug_ << '\n';
}
// 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];
// Print the symbols being reduced, and their result.
*yycdebug_ << "Reducing stack by rule " << yyrule - 1
- << " (line " << yylno << "):" << std::endl;
+ << " (line " << yylno << "):\n";
// The symbols being reduced.
for (int yyi = 0; yyi < yynrhs; yyi++)
YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
diff --git a/doc/bison.texi b/doc/bison.texi
index e1f6a546..8b1c246f 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -11174,13 +11174,13 @@ calcxx_driver::parse (const std::string &f)
void
calcxx_driver::error (const yy::location& l, const std::string& m)
@{
- std::cerr << l << ": " << m << std::endl;
+ std::cerr << l << ": " << m << '\n';
@}
void
calcxx_driver::error (const std::string& m)
@{
- std::cerr << m << std::endl;
+ std::cerr << m << '\n';
@}
@end example
@@ -11533,7 +11533,7 @@ main (int argc, char *argv[])
else if (argv[i] == std::string ("-s"))
driver.trace_scanning = true;
else if (!driver.parse (argv[i]))
- std::cout << driver.result << std::endl;
+ std::cout << driver.result << '\n';
else
res = 1;
return res;
diff --git a/etc/bench.pl.in b/etc/bench.pl.in
index cbd9473d..39b8d042 100755
--- a/etc/bench.pl.in
+++ b/etc/bench.pl.in
@@ -738,7 +738,7 @@ yy::parser::token_type yylex(yy::parser::semantic_type* yylvalp,
void
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[])
diff --git a/examples/variant.yy b/examples/variant.yy
index 99426cab..1dcd1d08 100644
--- a/examples/variant.yy
+++ b/examples/variant.yy
@@ -85,7 +85,7 @@ typedef std::list<std::string> strings_type;
%%
result:
- list { std::cout << $1 << std::endl; }
+ list { std::cout << $1 << '\n'; }
;
list:
@@ -135,7 +135,7 @@ namespace yy
void
parser::error (const parser::location_type& loc, const std::string& msg)
{
- std::cerr << loc << ": " << msg << std::endl;
+ std::cerr << loc << ": " << msg << '\n';
}
}
diff --git a/tests/actions.at b/tests/actions.at
index 7d876709..8ccd7124 100644
--- a/tests/actions.at
+++ b/tests/actions.at
@@ -203,7 +203,7 @@ AT_DATA_GRAMMAR([[input.y]],
]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)]])[; }
%%
]AT_YYERROR_DEFINE[
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 7b2b916a..1d7ac5a4 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -69,7 +69,7 @@ if $BISON_CXX_WORKS; then
int main ()
{
- std::cout << "Works" << std::endl;
+ std::cout << "Works\n";
}
EOF
$CXX $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS -o conftest conftest.cc
diff --git a/tests/c++.at b/tests/c++.at
index 60292f4e..dc79d6b9 100644
--- a/tests/c++.at
+++ b/tests/c++.at
@@ -49,7 +49,7 @@ check (const T& in, const std::string& s)
os << in;
if (os.str () != s)
{
- std::cerr << "fail: " << os.str () << ", expected: " << s << std::endl;
+ std::cerr << "fail: " << os.str () << ", expected: " << s << '\n';
return false;
}
return true;
@@ -140,13 +140,13 @@ int main()
{
{
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::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:
- list { std::cout << $][1 << std::endl; }
+ list { std::cout << $][1 << '\n'; }
;
list:
@@ -504,7 +504,7 @@ void
]$1[::parser::error (const ]$1[::parser::location_type &loc,
const std::string &msg)
{
- std::cerr << "At " << loc << ": " << msg << std::endl;
+ std::cerr << "At " << loc << ": " << msg << '\n';
}
]AT_MAIN_DEFINE[
@@ -572,7 +572,7 @@ AT_DATA_GRAMMAR([[input.y]],
%nonassoc 'a' ;
%destructor {
- std::cerr << "Discarding 'a'." << std::endl;
+ std::cerr << "Discarding 'a'.\n";
} 'a'
%%
@@ -581,7 +581,7 @@ start: error-reduce consistent-error 'a' { USE ($3); };
error-reduce:
'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:
@@ -605,7 +605,7 @@ yylex (yy::parser::semantic_type *)
void
yy::parser::error (const std::string &m)
{
- std::cerr << m << std::endl;
+ std::cerr << m << '\n';
}
]AT_MAIN_DEFINE[
@@ -651,7 +651,7 @@ start:
;
thing:
- error { std::cerr << "caught error" << std::endl; }
+ error { std::cerr << "caught error\n"; }
| item
;
@@ -681,7 +681,7 @@ yylex (yy::parser::semantic_type *)
void
yy::parser::error (const std::string &m)
{
- std::cerr << "error: " << m << std::endl;
+ std::cerr << "error: " << m << '\n';
}
]AT_MAIN_DEFINE[
]])
@@ -797,7 +797,7 @@ $1
std::cerr << sep << *i;
sep = ", ";
}
- std::cerr << " }" << std::endl;
+ std::cerr << " }\n";
}
}
};
@@ -929,11 +929,11 @@ main (int argc, const char *argv[])
}
catch (const std::exception& e)
{
- std::cerr << "exception caught: " << e.what () << std::endl;
+ std::cerr << "exception caught: " << e.what () << '\n';
}
catch (...)
{
- std::cerr << "unknown exception caught" << std::endl;
+ std::cerr << "unknown exception caught\n";
}
Object::log (YY_NULLPTR, "end");
assert (Object::empty());
diff --git a/tests/headers.at b/tests/headers.at
index 9c1d00bc..4a49257e 100644
--- a/tests/headers.at
+++ b/tests/headers.at
@@ -181,7 +181,7 @@ extern "C"
do { \
int res = S; \
if (res) \
- std::cerr << #S": " << res << std::endl; \
+ std::cerr << #S": " << res << '\n'; \
} while (false)
int
diff --git a/tests/local.at b/tests/local.at
index 5a459c64..f25a7081 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -539,7 +539,7 @@ m4_define([AT_YYERROR_DEFINE(c++)],
void
]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 (...)
{
- std::cerr << "Inner caught" << std::endl;
+ std::cerr << "Inner caught\n";
throw;
}
}
@@ -905,7 +905,7 @@ int main()
}
catch (...)
{
- std::cerr << "Outer caught" << std::endl;
+ std::cerr << "Outer caught\n";
return 0;
}
return 1;
diff --git a/tests/types.at b/tests/types.at
index 0c108d9d..e1769819 100644
--- a/tests/types.at
+++ b/tests/types.at
@@ -243,7 +243,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
%define api.value.type variant],
[%token <int> '1';
%token <std::string> '2';],
- ['1' '2' { std::cout << $1 << ", " << $2 << std::endl; }],
+ ['1' '2' { std::cout << $1 << ", " << $2 << '\n'; }],
["12"],
[if (res == '1')
AT_VAL.build(10);