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-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>
doc: use C++ headers.
Also, it is possible to add code to the parser's constructors using
"%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
with identifiers in the target language. For instance
%token FILE for ERROR
- %define token.prefix "TOK_"
+ %define api.tokens.prefix "TOK_"
%%
start: FILE for ERROR;
# undefined. If FIELD = id, prepend the prefix.
m4_define([b4_symbol],
[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_($@)])])
# Default values for %define.
# ---------------------------
-# If the %token.prefix, it is empty.
-m4_percent_define_default([[token.prefix]], [[]])
+# If the api.tokens.prefix, it is empty.
+m4_percent_define_default([[api.tokens.prefix]], [[]])
# -----------------------------------------
# Output the definition of this token as #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
])
# ---------------------------------------
# Output the definition of this token as an 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)
# Output the definition of this token as an enum.
m4_define([b4_token_enum],
[ /** 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;
])
@end itemize
@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
@findex %define error-verbose
@itemize
@end itemize
@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 deffn
@c ---------------------------------------------------------- %define
allows for nicer error messages referring to ``end of file'' instead of
``$end''. Similarly user friendly names are provided for each symbol.
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
@example
-%define token.prefix "TOK_"
+%define api.tokens.prefix "TOK_"
%token END 0 "end of file"
%token ASSIGN ":="
%token <sval> IDENTIFIER "identifier"
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 %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_"]])
## ----------------------- ##
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" %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([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
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" %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_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" %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_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" %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_JAVA_MINIMAL([[%name-prefix "Prefix"]])
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_MINIMAL([[%define parser_class_name "ParserClassName"]])
[m4_bregexp([$3], [name-prefix "\([^"]*\)"], [\1])],
[yy])])
m4_pushdef([AT_TOKEN_PREFIX],
-[m4_bmatch([$3], [%define token.prefix ".*"],
- [m4_bregexp([$3], [%define token.prefix "\(.*\)"], [\1])])])
+[m4_bmatch([$3], [%define api.tokens.prefix ".*"],
+ [m4_bregexp([$3], [%define api.tokens.prefix "\(.*\)"], [\1])])])
# yyerror receives the location if %location & %pure & (%glr or %parse-param).
m4_pushdef([AT_YYERROR_ARG_LOC_IF],
[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],