mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 16:53:02 +00:00
Rename token.prefix as api.tokens.prefix.
Discussed here. http://lists.gnu.org/archive/html/bison-patches/2009-05/msg00024.html. * NEWS, data/bison.m4, data/c.m4, data/java.m4, doc/bison.texinfo, * tests/c++.at, tests/calc.at, tests/java.at, tests/local.at (token.prefix): Rename as... (api.tokens.prefix): this.
This commit is contained in:
11
ChangeLog
11
ChangeLog
@@ -1,3 +1,14 @@
|
|||||||
|
2009-05-15 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
|
Rename token.prefix as api.tokens.prefix.
|
||||||
|
Discussed here.
|
||||||
|
http://lists.gnu.org/archive/html/bison-patches/2009-05/msg00024.html.
|
||||||
|
|
||||||
|
* NEWS, data/bison.m4, data/c.m4, data/java.m4, doc/bison.texinfo,
|
||||||
|
* tests/c++.at, tests/calc.at, tests/java.at, tests/local.at
|
||||||
|
(token.prefix): Rename as...
|
||||||
|
(api.tokens.prefix): this.
|
||||||
|
|
||||||
2009-05-11 Akim Demaille <demaille@gostai.com>
|
2009-05-11 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
doc: use C++ headers.
|
doc: use C++ headers.
|
||||||
|
|||||||
6
NEWS
6
NEWS
@@ -9,14 +9,14 @@ Bison News
|
|||||||
Also, it is possible to add code to the parser's constructors using
|
Also, it is possible to add code to the parser's constructors using
|
||||||
"%code init" and "%define init_throws".
|
"%code init" and "%define init_throws".
|
||||||
|
|
||||||
** Variable token.prefix
|
** Variable api.tokens.prefix
|
||||||
|
|
||||||
The variable token.prefix changes the way tokens are identified in
|
The variable api.tokens.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 token.prefix "TOK_"
|
%define api.tokens.prefix "TOK_"
|
||||||
%%
|
%%
|
||||||
start: FILE for ERROR;
|
start: FILE for ERROR;
|
||||||
|
|
||||||
|
|||||||
@@ -355,7 +355,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([token.prefix])],
|
[id], [m4_do([b4_percent_define_get([api.tokens.prefix])],
|
||||||
[b4_symbol_([$1], [id])])],
|
[b4_symbol_([$1], [id])])],
|
||||||
[b4_symbol_($@)])])
|
[b4_symbol_($@)])])
|
||||||
|
|
||||||
@@ -769,8 +769,8 @@ m4_define([b4_percent_code_ifdef],
|
|||||||
|
|
||||||
# Default values for %define.
|
# Default values for %define.
|
||||||
# ---------------------------
|
# ---------------------------
|
||||||
# If the %token.prefix, it is empty.
|
# If the api.tokens.prefix, it is empty.
|
||||||
m4_percent_define_default([[token.prefix]], [[]])
|
m4_percent_define_default([[api.tokens.prefix]], [[]])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ static const b4_int_type_for([$2]) yy$1[[]] =
|
|||||||
# -----------------------------------------
|
# -----------------------------------------
|
||||||
# Output the definition of this token as #define.
|
# Output the definition of this token as #define.
|
||||||
m4_define([b4_token_define],
|
m4_define([b4_token_define],
|
||||||
[#define b4_percent_define_get([token.prefix])$1 $2
|
[#define b4_percent_define_get([api.tokens.prefix])$1 $2
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ m4_map([b4_token_define], [$@])])
|
|||||||
# ---------------------------------------
|
# ---------------------------------------
|
||||||
# Output the definition of this token as an enum.
|
# Output the definition of this token as an enum.
|
||||||
m4_define([b4_token_enum],
|
m4_define([b4_token_enum],
|
||||||
[b4_percent_define_get([token.prefix])$1 = $2])
|
[b4_percent_define_get([api.tokens.prefix])$1 = $2])
|
||||||
|
|
||||||
|
|
||||||
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
# b4_token_enums(LIST-OF-PAIRS-TOKEN-NAME-TOKEN-NUMBER)
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ m4_define([b4_integral_parser_table_define],
|
|||||||
# Output the definition of this token as an enum.
|
# Output the definition of this token as an enum.
|
||||||
m4_define([b4_token_enum],
|
m4_define([b4_token_enum],
|
||||||
[ /** Token number, to be returned by the scanner. */
|
[ /** Token number, to be returned by the scanner. */
|
||||||
static final int b4_percent_define_get([token.prefix])$1 = $2;
|
static final int b4_percent_define_get([api.tokens.prefix])$1 = $2;
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4902,6 +4902,43 @@ More user feedback will help to stabilize it.)
|
|||||||
@end itemize
|
@end itemize
|
||||||
@c api.push-pull
|
@c api.push-pull
|
||||||
|
|
||||||
|
@item api.tokens.prefix
|
||||||
|
@findex %define api.tokens.prefix
|
||||||
|
|
||||||
|
@itemize
|
||||||
|
@item Languages(s): all
|
||||||
|
|
||||||
|
@item Purpose:
|
||||||
|
Add a prefix to the token names when generating their definition in the
|
||||||
|
target language. For instance
|
||||||
|
|
||||||
|
@example
|
||||||
|
%token FILE for ERROR
|
||||||
|
%define api.tokens.prefix "TOK_"
|
||||||
|
%%
|
||||||
|
start: FILE for ERROR;
|
||||||
|
@end example
|
||||||
|
|
||||||
|
@noindent
|
||||||
|
generates the definition of the symbols @code{TOK_FILE}, @code{TOK_for},
|
||||||
|
and @code{TOK_ERROR} in the generated source files. In particular, the
|
||||||
|
scanner must use these prefixed token names, while the grammar itself
|
||||||
|
may still use the short names (as in the sample rule given above). The
|
||||||
|
generated informational files (@file{*.output}, @file{*.xml},
|
||||||
|
@file{*.dot}) are not modified by this prefix. See @ref{Calc++ Parser}
|
||||||
|
and @ref{Calc++ Scanner}, for a complete example.
|
||||||
|
|
||||||
|
@item Accepted Values:
|
||||||
|
Any string. Should be a valid identifier prefix in the target language,
|
||||||
|
in other words, it should typically be an identifier itself (sequence of
|
||||||
|
letters, underscores, and ---not at the beginning--- digits).
|
||||||
|
|
||||||
|
@item Default Value:
|
||||||
|
empty
|
||||||
|
@end itemize
|
||||||
|
@c api.tokens.prefix
|
||||||
|
|
||||||
|
|
||||||
@item error-verbose
|
@item error-verbose
|
||||||
@findex %define error-verbose
|
@findex %define error-verbose
|
||||||
@itemize
|
@itemize
|
||||||
@@ -5192,42 +5229,6 @@ is not already defined, so that the debugging facilities are compiled.
|
|||||||
@end itemize
|
@end itemize
|
||||||
@c parse.trace
|
@c parse.trace
|
||||||
|
|
||||||
@item token.prefix
|
|
||||||
@findex %define token.prefix
|
|
||||||
|
|
||||||
@itemize
|
|
||||||
@item Languages(s): all
|
|
||||||
|
|
||||||
@item Purpose:
|
|
||||||
Add a prefix to the token names when generating their definition in the
|
|
||||||
target language. For instance
|
|
||||||
|
|
||||||
@example
|
|
||||||
%token FILE for ERROR
|
|
||||||
%define token.prefix "TOK_"
|
|
||||||
%%
|
|
||||||
start: FILE for ERROR;
|
|
||||||
@end example
|
|
||||||
|
|
||||||
@noindent
|
|
||||||
generates the definition of the symbols @code{TOK_FILE}, @code{TOK_for},
|
|
||||||
and @code{TOK_ERROR} in the generated source files. In particular, the
|
|
||||||
scanner must use these prefixed token names, while the grammar itself
|
|
||||||
may still use the short names (as in the sample rule given above). The
|
|
||||||
generated informational files (@file{*.output}, @file{*.xml},
|
|
||||||
@file{*.dot}) are not modified by this prefix. See @ref{Calc++ Parser}
|
|
||||||
and @ref{Calc++ Scanner}, for a complete example.
|
|
||||||
|
|
||||||
@item Accepted Values:
|
|
||||||
Any string. Should be a valid identifier prefix in the target language,
|
|
||||||
in other words, it should typically be an identifier itself (sequence of
|
|
||||||
letters, underscores, and ---not at the beginning--- digits).
|
|
||||||
|
|
||||||
@item Default Value:
|
|
||||||
empty
|
|
||||||
@end itemize
|
|
||||||
@c token.prefix
|
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
@end deffn
|
@end deffn
|
||||||
@c ---------------------------------------------------------- %define
|
@c ---------------------------------------------------------- %define
|
||||||
@@ -8817,11 +8818,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.
|
``$end''. Similarly user friendly names are provided for each symbol.
|
||||||
To avoid name clashes in the generated files (@pxref{Calc++ Scanner}),
|
To avoid name clashes in the generated files (@pxref{Calc++ Scanner}),
|
||||||
prefix tokens with @code{TOK_} (@pxref{Decl Summary,, token.prefix}).
|
prefix tokens with @code{TOK_} (@pxref{Decl Summary,, api.tokens.prefix}).
|
||||||
|
|
||||||
@comment file: calc++-parser.yy
|
@comment file: calc++-parser.yy
|
||||||
@example
|
@example
|
||||||
%define token.prefix "TOK_"
|
%define api.tokens.prefix "TOK_"
|
||||||
%token END 0 "end of file"
|
%token END 0 "end of file"
|
||||||
%token ASSIGN ":="
|
%token ASSIGN ":="
|
||||||
%token <sval> IDENTIFIER "identifier"
|
%token <sval> IDENTIFIER "identifier"
|
||||||
|
|||||||
@@ -199,7 +199,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 token.prefix "TOK_"]])
|
AT_CHECK_VARIANTS([[%define parse.assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n} %define api.tokens.prefix "TOK_"]])
|
||||||
|
|
||||||
|
|
||||||
## ----------------------- ##
|
## ----------------------- ##
|
||||||
|
|||||||
@@ -579,7 +579,7 @@ AT_CHECK_CALC_LALR([%define api.push-pull "both" %define api.pure %locations])
|
|||||||
AT_CHECK_CALC_LALR([%error-verbose %locations])
|
AT_CHECK_CALC_LALR([%error-verbose %locations])
|
||||||
|
|
||||||
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||||
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %define token.prefix "TOK_" %verbose %yacc])
|
AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_LALR([%debug])
|
AT_CHECK_CALC_LALR([%debug])
|
||||||
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||||
@@ -620,7 +620,7 @@ AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc" %verbo
|
|||||||
|
|
||||||
AT_CHECK_CALC_GLR([%debug])
|
AT_CHECK_CALC_GLR([%debug])
|
||||||
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||||
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %define token.prefix "TOK_" %verbose %yacc])
|
AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
@@ -650,7 +650,7 @@ AT_CHECK_CALC_LALR1_CC([%locations %error-verbose %name-prefix "calc" %verbose %
|
|||||||
AT_CHECK_CALC_LALR1_CC([%locations %error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_LALR1_CC([%locations %error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
||||||
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %define token.prefix "TOK_" %verbose %yacc])
|
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||||
|
|
||||||
@@ -679,6 +679,6 @@ AT_CHECK_CALC_GLR_CC([%debug])
|
|||||||
AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
|
||||||
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %define token.prefix "TOK_" %verbose %yacc])
|
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
|
||||||
|
|
||||||
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
|
||||||
|
|||||||
@@ -487,7 +487,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 token.prefix "TOK_"]])
|
AT_CHECK_JAVA_MINIMAL([[%define api.tokens.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"]])
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ m4_pushdef([AT_NAME_PREFIX],
|
|||||||
[m4_bregexp([$3], [name-prefix "\([^"]*\)"], [\1])],
|
[m4_bregexp([$3], [name-prefix "\([^"]*\)"], [\1])],
|
||||||
[yy])])
|
[yy])])
|
||||||
m4_pushdef([AT_TOKEN_PREFIX],
|
m4_pushdef([AT_TOKEN_PREFIX],
|
||||||
[m4_bmatch([$3], [%define token.prefix ".*"],
|
[m4_bmatch([$3], [%define api.tokens.prefix ".*"],
|
||||||
[m4_bregexp([$3], [%define token.prefix "\(.*\)"], [\1])])])
|
[m4_bregexp([$3], [%define api.tokens.prefix "\(.*\)"], [\1])])])
|
||||||
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
|
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
|
||||||
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
|
||||||
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
|
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
|
||||||
|
|||||||
Reference in New Issue
Block a user