mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
c++: demonstrate custom error messages in the examples
Let's use c++/glr to demonstrate custom error messages in C++ (not just in glr2.cc). * examples/c++/glr/c++-types.yy (report_syntax_error): New. * examples/c++/glr/c++-types.test: Adjust. * examples/c/bistromathic/parse.y: Comment changes. * tests/local.at (AT_YYERROR_DEFINE(c++)): Use a nicer way to print the lookakead's name.
This commit is contained in:
@@ -823,11 +823,8 @@ void
|
||||
++*nerrs;]])[]AT_LOCATION_IF([[
|
||||
std::cerr << ctx.location () << ": ";]])[
|
||||
std::cerr << "syntax error";
|
||||
{
|
||||
symbol_kind_type la = ctx.token ();
|
||||
if (la != symbol_kind::S_YYEMPTY)
|
||||
std::cerr << " on token [" << symbol_name (la) << ']';
|
||||
}
|
||||
if (!ctx.lookahead ().empty ())
|
||||
std::cerr << " on token [" << ctx.lookahead ().name () << ']';
|
||||
{
|
||||
enum { TOKENMAX = 10 };
|
||||
symbol_kind_type expected[TOKENMAX];
|
||||
|
||||
Reference in New Issue
Block a user