[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/4] yacc.c: install backward compatibility for YYERRCODE
From: |
Akim Demaille |
Subject: |
[PATCH 4/4] yacc.c: install backward compatibility for YYERRCODE |
Date: |
Tue, 28 Apr 2020 08:49:22 +0200 |
Some people have been using that symbol. Some even have #defined it
themselves.
https://lists.gnu.org/r/bison-patches/2020-04/msg00138.html
Let's provide backward compatibility, having it point to YYUNDEF, so
that an error message is generated.
* data/skeletons/yacc.c (YYERRCODE): New, at the exact same location
it was defined before.
---
TODO | 6 ++----
data/skeletons/yacc.c | 3 +++
src/parse-gram.c | 3 +++
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/TODO b/TODO
index 5301ba83..ea1f2d28 100644
--- a/TODO
+++ b/TODO
@@ -27,12 +27,10 @@ Beware that returning 0 is unclear: does it mean there are
no possible
lookahead, or that there are too many?
** YYerror
-yacc.c should `#define YYERRCODE YYerror` in the *.c for sake of the
-projects that used it. In particular
-
https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-runtime/intl/plural.y;h=a712255af4f2f739c93336d4ff6556d932a426a5;hb=HEAD
-should be updated.
+should be updated to not use YYERRCODE. Returning an undef token is good
+enough.
** Java
*** Examples
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 2f3c19a1..6fed7de5 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -746,6 +746,9 @@ enum { YYENOMEM = -2 };
} \
while (0)
+/* Backward compatibility with an undocumented macro.
+ Use ]b4_symbol(1, id)[ or ]b4_symbol(2, id)[. */
+#define YYERRCODE ]b4_symbol(2, id)[
]b4_locations_if([[
]b4_yylloc_default_define[
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
diff --git a/src/parse-gram.c b/src/parse-gram.c
index 21c201cc..f2a4eb91 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -931,6 +931,9 @@ enum { YYENOMEM = -2 };
} \
while (0)
+/* Backward compatibility with an undocumented macro.
+ Use GRAM_error or GRAM_UNDEF. */
+#define YYERRCODE GRAM_UNDEF
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends
--
2.26.2