summaryrefslogtreecommitdiff
path: root/perly.c
diff options
context:
space:
mode:
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2020-07-27 21:48:11 +0100
committerDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2020-08-06 14:55:10 +0100
commita9d4ef0f970b8b926f41fb1148174640f0c9325b (patch)
tree15c317fd10e9dd260fd81bc4a102ebf7dfa1d24f /perly.c
parent0a2b3d8846bc5c68e42def5b83d657754b4d07ce (diff)
downloadperl-a9d4ef0f970b8b926f41fb1148174640f0c9325b.tar.gz
Add support for Bison versions up to 3.7
This requires copying the `YY_CAST` and `YY_ATTRIBUTE_UNUSED` macros from the generated code, and extracting the `yysymbol_kind_t` enum if it's defined. We must also handle token type names with escaped double-quotes in them, since it now names the `YYEOF` and `YYUNDEF` tokens `"end of file"` and `"invalid token"` instead of `$end` and `$undefined`, respectively.
Diffstat (limited to 'perly.c')
-rw-r--r--perly.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/perly.c b/perly.c
index 2b152c7d87..091371937d 100644
--- a/perly.c
+++ b/perly.c
@@ -53,6 +53,24 @@ typedef signed char yysigned_char;
# define YY_NULLPTR NULL
#endif
+#ifndef YY_CAST
+# ifdef __cplusplus
+# define YY_CAST(Type, Val) static_cast<Type> (Val)
+# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
+# else
+# define YY_CAST(Type, Val) ((Type) (Val))
+# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
+# endif
+#endif
+
+#ifndef YY_ATTRIBUTE_UNUSED
+# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
+# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+# else
+# define YY_ATTRIBUTE_UNUSED
+# endif
+#endif
+
/* contains all the parser state tables; auto-generated from perly.y */
#include "perly.tab"