diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2020-11-11 08:42:16 +0100 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2020-11-11 09:08:57 +0100 |
commit | 21c147b6e5372563b7c4741deadaddb9354f4b09 (patch) | |
tree | 745dd8622b4e306d1ad9a334b921bd3dfaa59832 | |
parent | d3c575a6c6639a129d5ca84b60cc693fbd0cde68 (diff) | |
download | bison-21c147b6e5372563b7c4741deadaddb9354f4b09.tar.gz |
yacc.c: provide the Bison version as an integral macro
Suggested by Balazs Scheidler.
https://github.com/akimd/bison/issues/55
* src/muscle-tab.c (muscle_init): Move/rename `b4_version` to/as...
* src/output.c (prepare): `b4_version_string`.
Also define `b4_version`.
* data/skeletons/bison.m4, data/skeletons/c.m4, data/skeletons/d.m4,
* data/skeletons/java.m4: Adjust.
* doc/bison.texi: Document it.
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | data/skeletons/bison.m4 | 2 | ||||
-rw-r--r-- | data/skeletons/c.m4 | 8 | ||||
-rw-r--r-- | data/skeletons/d.m4 | 8 | ||||
-rw-r--r-- | data/skeletons/java.m4 | 8 | ||||
-rw-r--r-- | doc/bison.texi | 6 | ||||
-rw-r--r-- | src/muscle-tab.c | 3 | ||||
-rw-r--r-- | src/output.c | 4 | ||||
-rw-r--r-- | src/parse-gram.c | 2 |
9 files changed, 30 insertions, 17 deletions
@@ -7,6 +7,12 @@ GNU Bison NEWS In Yacc mode, all the tokens are defined twice: once as an enum, and then as a macro. YYEMPTY was missing its macro. +** Changes + + The YYBISON macro in generated "regular C parsers" (from the "yacc.c" + skeleton) used to be defined to 1. It is now defined to the version of + Bison as an integer (e.g., 30704 for version 3.7.4). + * Noteworthy changes in release 3.7.3 (2020-10-13) [stable] ** Bug fixes diff --git a/data/skeletons/bison.m4 b/data/skeletons/bison.m4 index 8c5fbdf5..365ee72e 100644 --- a/data/skeletons/bison.m4 +++ b/data/skeletons/bison.m4 @@ -49,7 +49,7 @@ m4_define([m4_shift4], [m4_shift(m4_shift(m4_shift(m4_shift($@))))]) # b4_generated_by # --------------- m4_define([b4_generated_by], -[b4_comment([A Bison parser, made by GNU Bison b4_version.]) +[b4_comment([A Bison parser, made by GNU Bison b4_version_string.]) ]) # b4_copyright(TITLE, [YEARS]) diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4 index c8689038..07148ef8 100644 --- a/data/skeletons/c.m4 +++ b/data/skeletons/c.m4 @@ -58,11 +58,11 @@ m4_define([b4_cpp_guard_close], # b4_pull_flag if they use the values of the %define variables api.pure or # api.push-pull. m4_define([b4_identification], -[[/* Identify Bison output. */ -#define YYBISON 1 +[[/* Identify Bison output, and Bison version. */ +#define YYBISON ]b4_version[ -/* Bison version. */ -#define YYBISON_VERSION "]b4_version[" +/* Bison version string. */ +#define YYBISON_VERSION "]b4_version_string[" /* Skeleton name. */ #define YYSKELETON_NAME ]b4_skeleton[]m4_ifdef([b4_pure_flag], [[ diff --git a/data/skeletons/d.m4 b/data/skeletons/d.m4 index edb0c49e..0c283519 100644 --- a/data/skeletons/d.m4 +++ b/data/skeletons/d.m4 @@ -103,12 +103,12 @@ m4_define([b4_location_type_if], # b4_identification # ----------------- m4_define([b4_identification], -[/** Version number for the Bison executable that generated this parser. */ - public static immutable string yy_bison_version = "b4_version"; +[[/** Version number for the Bison executable that generated this parser. */ + public static immutable string yy_bison_version = "]b4_version_string["; /** Name of the skeleton that generated this parser. */ - public static immutable string yy_bison_skeleton = b4_skeleton; -]) + public static immutable string yy_bison_skeleton = ]b4_skeleton[; +]]) ## ------------ ## diff --git a/data/skeletons/java.m4 b/data/skeletons/java.m4 index e4e2fad8..7b4f7b5c 100644 --- a/data/skeletons/java.m4 +++ b/data/skeletons/java.m4 @@ -71,12 +71,12 @@ m4_define([b4_lexer_if], # b4_identification # ----------------- m4_define([b4_identification], -[ /** Version number for the Bison executable that generated this parser. */ - public static final String bisonVersion = "b4_version"; +[[ /** Version number for the Bison executable that generated this parser. */ + public static final String bisonVersion = "]b4_version_string["; /** Name of the skeleton that generated this parser. */ - public static final String bisonSkeleton = b4_skeleton; -]) + public static final String bisonSkeleton = ]b4_skeleton[; +]]) ## ------------ ## diff --git a/doc/bison.texi b/doc/bison.texi index 416a8ec6..d38801db 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -15434,6 +15434,12 @@ Macro to discard a value from the parser stack and fake a lookahead token. @xref{Action Features}. @end deffn +@deffn {Macro} YYBISON +The version of Bison as an integer, for instance 30704 for version 3.7.4. +Defined in @file{yacc.c} only. Before version 3.7.4, @code{YYBISON} was +defined to 1. +@end deffn + @deffn {Variable} yychar External integer variable that contains the integer value of the lookahead token. (In a pure parser, it is a local variable within diff --git a/src/muscle-tab.c b/src/muscle-tab.c index 9d1c266e..c0c66690 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -127,9 +127,6 @@ muscle_init (void) muscle_table = hash_xinitialize (HT_INITIAL_CAPACITY, NULL, hash_muscle, hash_compare_muscles, muscle_entry_free); - - /* Version and input file. */ - MUSCLE_INSERT_STRING ("version", VERSION); } diff --git a/src/output.c b/src/output.c index d550c470..753b1bd7 100644 --- a/src/output.c +++ b/src/output.c @@ -42,6 +42,7 @@ #include "scan-skel.h" #include "symtab.h" #include "tables.h" +#include "strversion.h" static struct obstack format_obstack; @@ -807,6 +808,9 @@ prepare (void) char const *cp = getenv ("BISON_USE_PUSH_FOR_PULL"); bool use_push_for_pull_flag = cp && *cp && strtol (cp, 0, 10); + /* Versions. */ + MUSCLE_INSERT_STRING ("version_string", VERSION); + MUSCLE_INSERT_INT ("version", strversion_to_int (VERSION)); MUSCLE_INSERT_INT ("required_version", required_version); /* Flags. */ diff --git a/src/parse-gram.c b/src/parse-gram.c index 441fc97b..cfca03b5 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -46,7 +46,7 @@ USER NAME SPACE" below. */ /* Identify Bison output. */ -#define YYBISON 1 +#define YYBISON 30703 /* Bison version. */ #define YYBISON_VERSION "3.7.3.7-d831b" |