summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <demaille@gostai.com>2009-05-15 16:06:31 +0200
committerAkim Demaille <demaille@gostai.com>2009-05-15 16:10:52 +0200
commit4c6622c2dd5e9383c89565ff3d9eadeeafc064f4 (patch)
tree587933b01d0cf9eb5781b66e5f678ff0ad435762
parent3c248d705d539b9383700d592303d6de4a2a7d76 (diff)
downloadbison-4c6622c2dd5e9383c89565ff3d9eadeeafc064f4.tar.gz
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.
-rw-r--r--ChangeLog11
-rw-r--r--NEWS6
-rw-r--r--data/bison.m46
-rw-r--r--data/c.m44
-rw-r--r--data/java.m42
-rw-r--r--doc/bison.texinfo77
-rw-r--r--tests/c++.at2
-rw-r--r--tests/calc.at8
-rw-r--r--tests/java.at2
-rw-r--r--tests/local.at4
10 files changed, 67 insertions, 55 deletions
diff --git a/ChangeLog b/ChangeLog
index b7534e36..71cf3a8a 100644
--- a/ChangeLog
+++ b/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>
doc: use C++ headers.
diff --git a/NEWS b/NEWS
index cef62ee5..76d8f4b2 100644
--- a/NEWS
+++ b/NEWS
@@ -9,14 +9,14 @@ Bison News
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;
diff --git a/data/bison.m4 b/data/bison.m4
index 9f88b6a6..5d97a29e 100644
--- a/data/bison.m4
+++ b/data/bison.m4
@@ -355,7 +355,7 @@ m4_define([b4_symbol_],
# 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_($@)])])
@@ -769,8 +769,8 @@ m4_define([b4_percent_code_ifdef],
# 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]], [[]])
diff --git a/data/c.m4 b/data/c.m4
index 6a9d577e..33a4186c 100644
--- a/data/c.m4
+++ b/data/c.m4
@@ -190,7 +190,7 @@ static const b4_int_type_for([$2]) yy$1[[]] =
# -----------------------------------------
# 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
])
@@ -208,7 +208,7 @@ m4_map([b4_token_define], [$@])])
# ---------------------------------------
# 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)
diff --git a/data/java.m4 b/data/java.m4
index 6636bd69..690d8858 100644
--- a/data/java.m4
+++ b/data/java.m4
@@ -147,7 +147,7 @@ m4_define([b4_integral_parser_table_define],
# 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;
])
diff --git a/doc/bison.texinfo b/doc/bison.texinfo
index aa74c9ef..744641a0 100644
--- a/doc/bison.texinfo
+++ b/doc/bison.texinfo
@@ -4902,6 +4902,43 @@ More user feedback will help to stabilize it.)
@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
@@ -5192,42 +5229,6 @@ is not already defined, so that the debugging facilities are compiled.
@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
@@ -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
``$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"
diff --git a/tests/c++.at b/tests/c++.at
index 55a6b3a7..608024ee 100644
--- a/tests/c++.at
+++ b/tests/c++.at
@@ -199,7 +199,7 @@ AT_CHECK_VARIANTS([])
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_"]])
## ----------------------- ##
diff --git a/tests/calc.at b/tests/calc.at
index 5ad0507d..24a50800 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -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 %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])
@@ -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([%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])
@@ -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 %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}])
@@ -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([%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}])
diff --git a/tests/java.at b/tests/java.at
index 901551f2..fa96558c 100644
--- a/tests/java.at
+++ b/tests/java.at
@@ -487,7 +487,7 @@ AT_CHECK_JAVA_GREP([[class YYParser]])
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"]])
diff --git a/tests/local.at b/tests/local.at
index bfd573a4..c796be9c 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -88,8 +88,8 @@ m4_pushdef([AT_NAME_PREFIX],
[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])],