bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 5/5] glr.c: add support for parse.error=custom


From: Akim Demaille
Subject: [PATCH 5/5] glr.c: add support for parse.error=custom
Date: Wed, 29 Jan 2020 19:49:17 +0100

* data/skeletons/glr.c (yyreportSyntaxError): Call the user's
yyreport_syntax_error in custom mode.
* tests/calc.at: Check it.
---
 data/skeletons/glr.c | 19 +++++++++++++++++++
 tests/calc.at        |  3 ++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index 26ba01db..a3b0e69e 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -2180,6 +2180,25 @@ yysyntax_error_arguments (const yyGLRStack* yystackp,
 }
 ]])[
 
+]m4_case(b4_percent_define_get([[parse.error]]),
+         [custom],
+[[/* User defined function to report a syntax error.  */
+typedef yyGLRStack yyparse_context_t;
+static int
+yyreport_syntax_error (const yyGLRStack* yystackp]b4_user_formals[);
+
+]b4_locations_if([[/*  The location of this context.  */
+static YYLTYPE *
+yyparse_context_location (const yyGLRStack *yystackp) YY_ATTRIBUTE_UNUSED;
+
+static YYLTYPE *
+yyparse_context_location (const yyGLRStack *yystackp)
+{
+  YYUSE (yystackp);
+  return &yylloc;
+}]])])[
+
+
 static void
 yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
 {
diff --git a/tests/calc.at b/tests/calc.at
index 0de22373..7dd4263b 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -877,8 +877,9 @@ AT_CHECK_CALC_GLR([%define parse.error verbose])
 AT_CHECK_CALC_GLR([%define api.pure %locations])
 AT_CHECK_CALC_GLR([%define parse.error verbose %locations])
 
-AT_CHECK_CALC_GLR([%define parse.error verbose %locations %defines 
%name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define parse.error custom %locations %defines %name-prefix 
"calc" %verbose %yacc])
 AT_CHECK_CALC_GLR([%define parse.error detailed %locations %defines 
%name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define parse.error verbose %locations %defines 
%name-prefix "calc" %verbose %yacc])
 
 AT_CHECK_CALC_GLR([%debug])
 AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines 
%name-prefix "calc" %verbose %yacc])
-- 
2.25.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]