api.tokens.prefix -> api.token.prefix

See
http://lists.gnu.org/archive/html/bison-patches/2012-02/msg00045.html
Note that api.tokens.prefix has not been released, yet.

* NEWS, data/bison.m4, doc/bison.texi, tests/c++.at,
* tests/calc.at, tests/java.at, tests/local.at: Do it.
* src/muscle-tab.c (muscle_percent_variable_update): Ensure
backward compatibility.
This commit is contained in:
Akim Demaille
2012-10-16 10:51:38 +02:00
parent f60321dc59
commit 2a6b66c5fd
8 changed files with 26 additions and 23 deletions

6
NEWS
View File

@@ -195,14 +195,14 @@ GNU Bison NEWS
used by the scanner, or rejecting invalid combinations from a used by the scanner, or rejecting invalid combinations from a
factory invoked by the user actions). factory invoked by the user actions).
** Variable api.tokens.prefix ** Variable api.token.prefix
The variable api.tokens.prefix changes the way tokens are identified in The variable api.token.prefix changes the way tokens are identified in
the generated files. This is especially useful to avoid collisions the generated files. This is especially useful to avoid collisions
with identifiers in the target language. For instance with identifiers in the target language. For instance
%token FILE for ERROR %token FILE for ERROR
%define api.tokens.prefix "TOK_" %define api.token.prefix "TOK_"
%% %%
start: FILE for ERROR; start: FILE for ERROR;

View File

@@ -333,7 +333,7 @@ m4_define([b4_symbol_],
# undefined. If FIELD = id, prepend the prefix. # undefined. If FIELD = id, prepend the prefix.
m4_define([b4_symbol], m4_define([b4_symbol],
[m4_case([$2], [m4_case([$2],
[id], [m4_do([b4_percent_define_get([api.tokens.prefix])], [id], [m4_do([b4_percent_define_get([api.token.prefix])],
[b4_symbol_([$1], [id])])], [b4_symbol_([$1], [id])])],
[b4_symbol_($@)])]) [b4_symbol_($@)])])
@@ -790,8 +790,8 @@ m4_define([b4_percent_code_ifdef],
# Default values for %define. # Default values for %define.
# --------------------------- # ---------------------------
# If the api.tokens.prefix, it is empty. # If the api.token.prefix, it is empty.
m4_percent_define_default([[api.tokens.prefix]], [[]]) m4_percent_define_default([[api.token.prefix]], [[]])
# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT]) # b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT]) # b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])

View File

@@ -5546,9 +5546,9 @@ More user feedback will help to stabilize it.)
@c ================================================== api.tokens.prefix @c ================================================== api.token.prefix
@item api.tokens.prefix @item api.token.prefix
@findex %define api.tokens.prefix @findex %define api.token.prefix
@itemize @itemize
@item Languages(s): all @item Languages(s): all
@@ -5559,7 +5559,7 @@ target language. For instance
@example @example
%token FILE for ERROR %token FILE for ERROR
%define api.tokens.prefix "TOK_" %define api.token.prefix "TOK_"
%% %%
start: FILE for ERROR; start: FILE for ERROR;
@end example @end example
@@ -5580,8 +5580,10 @@ letters, underscores, and ---not at the beginning--- digits).
@item Default Value: @item Default Value:
empty empty
@item History:
introduced in Bison 2.8
@end itemize @end itemize
@c api.tokens.prefix @c api.token.prefix
@c ================================================== lex_symbol @c ================================================== lex_symbol
@@ -10098,7 +10100,7 @@ So for each token type, Bison generates named constructors as follows.
@deftypemethod {symbol_type} {} make_@var{token} (const @var{value_type}& @var{value}, const location_type& @var{location}) @deftypemethod {symbol_type} {} make_@var{token} (const @var{value_type}& @var{value}, const location_type& @var{location})
@deftypemethodx {symbol_type} {} make_@var{token} (const location_type& @var{location}) @deftypemethodx {symbol_type} {} make_@var{token} (const location_type& @var{location})
Build a complete terminal symbol for the token type @var{token} (not Build a complete terminal symbol for the token type @var{token} (not
including the @code{api.tokens.prefix}) whose possible semantic value is including the @code{api.token.prefix}) whose possible semantic value is
@var{value} of adequate @var{value_type}. If location tracking is enabled, @var{value} of adequate @var{value_type}. If location tracking is enabled,
also pass the @var{location}. also pass the @var{location}.
@end deftypemethod @end deftypemethod
@@ -10106,7 +10108,7 @@ also pass the @var{location}.
For instance, given the following declarations: For instance, given the following declarations:
@example @example
%define api.tokens.prefix "TOK_" %define api.token.prefix "TOK_"
%token <std::string> IDENTIFIER; %token <std::string> IDENTIFIER;
%token <int> INTEGER; %token <int> INTEGER;
%token COLON; %token COLON;
@@ -10428,11 +10430,11 @@ The token numbered as 0 corresponds to end of file; the following line
allows for nicer error messages referring to ``end of file'' instead of allows for nicer error messages referring to ``end of file'' instead of
``$end''. Similarly user friendly names are provided for each symbol. To ``$end''. Similarly user friendly names are provided for each symbol. To
avoid name clashes in the generated files (@pxref{Calc++ Scanner}), prefix avoid name clashes in the generated files (@pxref{Calc++ Scanner}), prefix
tokens with @code{TOK_} (@pxref{%define Summary,,api.tokens.prefix}). tokens with @code{TOK_} (@pxref{%define Summary,,api.token.prefix}).
@comment file: calc++-parser.yy @comment file: calc++-parser.yy
@example @example
%define api.tokens.prefix "TOK_" %define api.token.prefix "TOK_"
%token %token
END 0 "end of file" END 0 "end of file"
ASSIGN ":=" ASSIGN ":="

View File

@@ -398,6 +398,7 @@ muscle_percent_variable_update (char const *variable, location variable_loc)
const conversion_type conversion[] = const conversion_type conversion[] =
{ {
{ "api.push_pull", "api.push-pull", }, { "api.push_pull", "api.push-pull", },
{ "api.tokens.prefix", "api.token.prefix", },
{ "location_type", "api.location.type", }, { "location_type", "api.location.type", },
{ "lr.keep_unreachable_states", "lr.keep-unreachable-states", }, { "lr.keep_unreachable_states", "lr.keep-unreachable-states", },
{ "namespace", "api.namespace", }, { "namespace", "api.namespace", },

View File

@@ -202,7 +202,7 @@ AT_CHECK_VARIANTS([])
AT_CHECK_VARIANTS([%define parse.assert]) AT_CHECK_VARIANTS([%define parse.assert])
AT_CHECK_VARIANTS([[%define parse.assert %code {\n#define ONE_STAGE_BUILD\n}]]) AT_CHECK_VARIANTS([[%define parse.assert %code {\n#define ONE_STAGE_BUILD\n}]])
AT_CHECK_VARIANTS([[%define parse.assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n}]]) AT_CHECK_VARIANTS([[%define parse.assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n}]])
AT_CHECK_VARIANTS([[%define parse.assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n} %define api.tokens.prefix "TOK_"]]) AT_CHECK_VARIANTS([[%define parse.assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n} %define api.token.prefix "TOK_"]])
## ----------------------- ## ## ----------------------- ##

View File

@@ -647,7 +647,7 @@ AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %locations])
AT_CHECK_CALC_LALR([%define parse.error verbose %locations]) AT_CHECK_CALC_LALR([%define parse.error verbose %locations])
AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %define api.prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc]) AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %name-prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc])
AT_CHECK_CALC_LALR([%debug]) AT_CHECK_CALC_LALR([%debug])
AT_CHECK_CALC_LALR([%define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR([%define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
@@ -690,7 +690,7 @@ AT_CHECK_CALC_GLR([%define parse.error verbose %locations %defines %name-prefix
AT_CHECK_CALC_GLR([%debug]) AT_CHECK_CALC_GLR([%debug])
AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %define api.prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc]) AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %define api.prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc])
AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
@@ -723,7 +723,7 @@ AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %define api.prefi
AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%defines %locations %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) AT_CHECK_CALC_LALR1_CC([%defines %locations %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}])
@@ -758,7 +758,7 @@ AT_CHECK_CALC_GLR_CC([%debug])
AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc]) AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug %name-prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc])
AT_CHECK_CALC_GLR_CC([%locations %defines %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) AT_CHECK_CALC_GLR_CC([%locations %defines %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}])
AT_CHECK_CALC_GLR_CC([%locations %defines %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) AT_CHECK_CALC_GLR_CC([%locations %defines %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}])

View File

@@ -461,7 +461,7 @@ AT_CHECK_JAVA_GREP([[class YYParser]])
AT_CHECK_JAVA_MINIMAL([[%name-prefix "Prefix"]]) AT_CHECK_JAVA_MINIMAL([[%name-prefix "Prefix"]])
AT_CHECK_JAVA_GREP([[class PrefixParser]]) AT_CHECK_JAVA_GREP([[class PrefixParser]])
AT_CHECK_JAVA_MINIMAL([[%define api.tokens.prefix "TOK_"]]) AT_CHECK_JAVA_MINIMAL([[%define api.token.prefix "TOK_"]])
AT_CHECK_JAVA_GREP([[.*TOK_END.*]]) AT_CHECK_JAVA_GREP([[.*TOK_END.*]])
AT_CHECK_JAVA_MINIMAL([[%define parser_class_name "ParserClassName"]]) AT_CHECK_JAVA_MINIMAL([[%define parser_class_name "ParserClassName"]])

View File

@@ -153,8 +153,8 @@ m4_pushdef([AT_NAME_PREFIX],
[m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])], [m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])],
[yy])]) [yy])])
m4_pushdef([AT_TOKEN_PREFIX], m4_pushdef([AT_TOKEN_PREFIX],
[m4_bmatch([$3], [%define api.tokens.prefix ".*"], [m4_bmatch([$3], [%define api.token.prefix ".*"],
[m4_bregexp([$3], [%define api.tokens.prefix "\(.*\)"], [\1])])]) [m4_bregexp([$3], [%define api.token.prefix "\(.*\)"], [\1])])])
m4_pushdef([AT_API_prefix], m4_pushdef([AT_API_prefix],
[m4_bmatch([$3], [%define api\.prefix ".*"], [m4_bmatch([$3], [%define api\.prefix ".*"],
[m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])], [m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])],