mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
muscle: factor the kind check in M4
* data/bison.m4 (b4_percent_define_check_kind): New.
Use it to check api.token.prefix.
* data/c++.m4: Check the kind of api.namespace.
* doc/bison.texi: Update a reference to former 'namespace' variable.
* tests/input.at ("%define" code variables): Check api.namespace.
This commit is contained in:
@@ -847,6 +847,21 @@ m4_define([b4_percent_define_if_define],
|
||||
b4_percent_define_if_define_([$1], [$2], $[1], $[2])])
|
||||
|
||||
|
||||
# b4_percent_define_check_kind(VARIABLE, KIND, [DIAGNOSTIC = complain])
|
||||
# ---------------------------------------------------------------------
|
||||
m4_define([b4_percent_define_check_kind],
|
||||
[b4_percent_define_ifdef_([$1],
|
||||
[m4_if(b4_percent_define_get_kind([[$1]]), [$2], [],
|
||||
[b4_error([m4_default([$3], [complain])],
|
||||
b4_percent_define_get_loc([$1]),
|
||||
[m4_case([$2],
|
||||
[code], [[%%define variable '%s' requires '{...}' values]],
|
||||
[keyword], [[%%define variable '%s' requires '...' values]],
|
||||
[string], [[%%define variable '%s' requires '"..."' values]])],
|
||||
[$1])])])dnl
|
||||
])
|
||||
|
||||
|
||||
# b4_percent_define_check_values(VALUES)
|
||||
# --------------------------------------
|
||||
# Mimic muscle_percent_define_check_values in ../src/muscle-tab.h exactly
|
||||
@@ -1018,12 +1033,7 @@ b4_percent_define_ifdef([api.prefix],
|
||||
|
||||
# api.token.prefix={...}
|
||||
# Make it a warning for those who used betas of Bison 3.0.
|
||||
b4_percent_define_ifdef([api.token.prefix],
|
||||
[m4_if(b4_percent_define_get_kind([[api.token.prefix]]), [code], [],
|
||||
[b4_error([deprecated],
|
||||
b4_percent_define_get_loc([api.token.prefix]),
|
||||
[[%%define variable '%s' requires '{...}' values]],
|
||||
[api.token.prefix])])])
|
||||
b4_percent_define_check_kind([api.token.prefix], [code], [deprecated])
|
||||
|
||||
# api.value.type >< %union.
|
||||
b4_percent_define_ifdef([api.value.type],
|
||||
|
||||
@@ -25,6 +25,11 @@ m4_include(b4_pkgdatadir/[c.m4])
|
||||
m4_define([b4_comment],
|
||||
[b4_comment_([$1], [$2// ], [$2// ])])
|
||||
|
||||
## -------- ##
|
||||
## Checks. ##
|
||||
## -------- ##
|
||||
|
||||
b4_percent_define_check_kind([api.namespace], [code], [deprecated])
|
||||
|
||||
## ---------------- ##
|
||||
## Default values. ##
|
||||
@@ -38,6 +43,7 @@ b4_percent_define_default([[parser_class_name]], [[parser]])
|
||||
# b4_percent_define_default([[api.location.type]], [[location]])
|
||||
|
||||
b4_percent_define_default([[filename_type]], [[std::string]])
|
||||
# Make it a warning for those who used betas of Bison 3.0.
|
||||
b4_percent_define_default([[api.namespace]], m4_defn([b4_prefix]))
|
||||
|
||||
b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
|
||||
|
||||
@@ -12758,7 +12758,7 @@ push parser, @code{yypush_parse}, @code{yypull_parse}, @code{yypstate},
|
||||
@code{yypstate_new} and @code{yypstate_delete} will also be renamed. For
|
||||
example, if you use @samp{%name-prefix "c_"}, the names become
|
||||
@code{c_parse}, @code{c_lex}, and so on. For C++ parsers, see the
|
||||
@code{%define namespace} documentation in this section.
|
||||
@code{%define api.namespace} documentation in this section.
|
||||
@end deffn
|
||||
|
||||
|
||||
|
||||
@@ -1441,19 +1441,23 @@ AT_CLEANUP
|
||||
AT_SETUP([["%define" code variables]])
|
||||
|
||||
m4_pushdef([AT_TEST],
|
||||
[AT_DATA([input.y],
|
||||
[[%define api.token.prefix ]$1[
|
||||
[AT_DATA([input.yy],
|
||||
[[%skeleton "lalr1.cc"
|
||||
%define api.namespace ]$1[quux]$2[
|
||||
%define api.token.prefix ]$1[quux]$2[
|
||||
%token TOK // Otherwise api.token.prefix is unused.
|
||||
%%
|
||||
start: %empty;
|
||||
start: TOK;
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([[input.y]], [0], [],
|
||||
[[input.y:1.9-24: warning: %define variable 'api.token.prefix' requires '{...}' values [-Wdeprecated]
|
||||
AT_BISON_CHECK([[input.yy]], [0], [],
|
||||
[[input.yy:3.9-24: warning: %define variable 'api.token.prefix' requires '{...}' values [-Wdeprecated]
|
||||
input.yy:2.9-21: warning: %define variable 'api.namespace' requires '{...}' values [-Wdeprecated]
|
||||
]])
|
||||
])
|
||||
|
||||
AT_TEST(["abc"])
|
||||
AT_TEST([abcde])
|
||||
AT_TEST([], [])
|
||||
AT_TEST(["], ["])
|
||||
m4_popdef([AT_TEST])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
Reference in New Issue
Block a user