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.
This commit is contained in:
Akim Demaille
2020-11-11 08:42:16 +01:00
parent d3c575a6c6
commit 21c147b6e5
9 changed files with 30 additions and 17 deletions

View File

@@ -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])

View File

@@ -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], [[

View File

@@ -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[;
]])
## ------------ ##

View File

@@ -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[;
]])
## ------------ ##