From 2142e5915576b124d76e3acecd34e4bbf538d2fe Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 7 Sep 2021 08:21:40 +0200 Subject: 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. --- examples/c++/README.md | 9 +++++++++ examples/c++/glr/README.md | 3 +++ examples/c++/glr/c++-types.test | 2 +- examples/c++/glr/c++-types.yy | 43 ++++++++++++++++++++++++++++++++++++++--- examples/c/bistromathic/parse.y | 5 +++-- tests/local.at | 7 ++----- 6 files changed, 58 insertions(+), 11 deletions(-) diff --git a/examples/c++/README.md b/examples/c++/README.md index 93cd09d5..dff3783e 100644 --- a/examples/c++/README.md +++ b/examples/c++/README.md @@ -39,6 +39,15 @@ examples. Extracted from the documentation: [A Complete C++ Example](https://www.gnu.org/software/bison/manual/html_node/A-Complete-C_002b_002b-Example.html). +## glr + +This example demonstrates the use of GLR parsers to handle (local) +ambiguities in the C++ language. See the node "Merging GLR Parses" in +Bison's documentation. + +It uses (Bison) variants to store objects as semantic values. It also +demonstrates custom error messages in C++. +