java: stype is obsoleted by api.value.type

This is consistent with the other %define variable names.

* data/java.m4: Use api.value.type instead of stype.
* doc/bison.texi, NEWS: Document that change.
* src/muscle-tab.c (muscle_percent_variable_update): Provide backward
compatibility.
* tests/java.at: Adjust.
This commit is contained in:
Akim Demaille
2012-12-31 11:13:50 +01:00
parent bdcbadbe37
commit 4119d1ea60
5 changed files with 26 additions and 22 deletions

17
NEWS
View File

@@ -198,6 +198,16 @@ 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).
** Renamed %define variables
The following variables have been renamed for consistency. Backward
compatibility is ensured, but upgrading is recommended.
lr.default-reductions -> lr.default-reduction
lr.keep-unreachable-states -> lr.keep-unreachable-state
namespace -> api.namespace
stype -> api.value.type
** Variable api.token.prefix ** Variable api.token.prefix
The variable api.token.prefix changes the way tokens are identified in The variable api.token.prefix changes the way tokens are identified in
@@ -214,14 +224,7 @@ GNU Bison NEWS
use these prefixed token names, although the grammar itself still use these prefixed token names, although the grammar itself still
uses the short names (as in the sample rule given above). uses the short names (as in the sample rule given above).
** Renamed %define variables
The following variables have been renamed for consistency. Backward
compatibility is ensured, but upgrading is recommended.
lr.default-reductions -> lr.default-reduction
lr.keep-unreachable-states -> lr.keep-unreachable-state
namespace -> api.namespace
** Variable parse.error ** Variable parse.error

View File

@@ -173,8 +173,8 @@ m4_define([b4_predicate_case], [ case $1:
## Default values. ## ## Default values. ##
## ---------------- ## ## ---------------- ##
m4_define([b4_yystype], [b4_percent_define_get([[stype]])]) m4_define([b4_yystype], [b4_percent_define_get([[api.value.type]])])
b4_percent_define_default([[stype]], [[Object]]) b4_percent_define_default([[api.value.type]], [[Object]])
# %name-prefix # %name-prefix
m4_define_default([b4_prefix], [[YY]]) m4_define_default([b4_prefix], [[YY]])

View File

@@ -11233,11 +11233,11 @@ semantic values' types (class names) should be specified in the
By default, the semantic stack is declared to have @code{Object} members, By default, the semantic stack is declared to have @code{Object} members,
which means that the class types you specify can be of any class. which means that the class types you specify can be of any class.
To improve the type safety of the parser, you can declare the common To improve the type safety of the parser, you can declare the common
superclass of all the semantic values using the @samp{%define stype} superclass of all the semantic values using the @samp{%define api.value.type}
directive. For example, after the following declaration: directive. For example, after the following declaration:
@example @example
%define stype "ASTNode" %define api.value.type "ASTNode"
@end example @end example
@noindent @noindent
@@ -11463,7 +11463,7 @@ The return type can be changed using @code{%define api.position.type
@deftypemethod {Lexer} {Object} getLVal () @deftypemethod {Lexer} {Object} getLVal ()
Return the semantic value of the last token that yylex returned. Return the semantic value of the last token that yylex returned.
The return type can be changed using @samp{%define stype The return type can be changed using @samp{%define api.value.type
"@var{class-name}".} "@var{class-name}".}
@end deftypemethod @end deftypemethod
@@ -11491,7 +11491,7 @@ Like @code{$@var{n}} but specifies a alternative type @var{typealt}.
@defvar $$ @defvar $$
The semantic value for the grouping made by the current rule. As a The semantic value for the grouping made by the current rule. As a
value, this is in the base type (@code{Object} or as specified by value, this is in the base type (@code{Object} or as specified by
@samp{%define stype}) as in not cast to the declared subtype because @samp{%define api.value.type}) as in not cast to the declared subtype because
casts are not allowed on the left-hand side of Java assignments. casts are not allowed on the left-hand side of Java assignments.
Use an explicit Java cast if the correct subtype is needed. Use an explicit Java cast if the correct subtype is needed.
@xref{Java Semantic Values}. @xref{Java Semantic Values}.
@@ -11573,7 +11573,7 @@ corresponds to these C macros.}.
@item @item
Java lacks unions, so @code{%union} has no effect. Instead, semantic Java lacks unions, so @code{%union} has no effect. Instead, semantic
values have a common base type: @code{Object} or as specified by values have a common base type: @code{Object} or as specified by
@samp{%define stype}. Angle brackets on @code{%token}, @code{type}, @samp{%define api.value.type}. Angle brackets on @code{%token}, @code{type},
@code{$@var{n}} and @code{$$} specify subtypes rather than fields of @code{$@var{n}} and @code{$$} specify subtypes rather than fields of
an union. The type of @code{$$}, even with angle brackets, is the base an union. The type of @code{$$}, even with angle brackets, is the base
type since Java casts are not allow on the left-hand side of assignments. type since Java casts are not allow on the left-hand side of assignments.
@@ -11749,7 +11749,7 @@ Whether the parser class is declared @code{public}. Default is false.
@xref{Java Bison Interface}. @xref{Java Bison Interface}.
@end deffn @end deffn
@deffn {Directive} {%define stype} "@var{class}" @deffn {Directive} {%define api.value.type} "@var{class}"
The base type of semantic values. Default is @code{Object}. The base type of semantic values. Default is @code{Object}.
@xref{Java Semantic Values}. @xref{Java Semantic Values}.
@end deffn @end deffn

View File

@@ -439,6 +439,7 @@ muscle_percent_variable_update (char const *variable, location variable_loc,
{ "lr.keep-unreachable-states", "lr.keep-unreachable-state", }, { "lr.keep-unreachable-states", "lr.keep-unreachable-state", },
{ "lr.keep_unreachable_states", "lr.keep-unreachable-state", }, { "lr.keep_unreachable_states", "lr.keep-unreachable-state", },
{ "namespace", "api.namespace", }, { "namespace", "api.namespace", },
{ "stype", "api.value.type", },
{ "variant=", "api.value.type=variant", }, { "variant=", "api.value.type=variant", },
{ "variant=true", "api.value.type=variant", }, { "variant=true", "api.value.type=variant", },
{ NULL, NULL, } { NULL, NULL, }

View File

@@ -408,7 +408,7 @@ AT_JAVA_COMPILE([[YYParser.java]])
# AT_CHECK_JAVA_MINIMAL_W_LEXER([1:DIRECTIVES], [2:LEX_THROWS], # AT_CHECK_JAVA_MINIMAL_W_LEXER([1:DIRECTIVES], [2:LEX_THROWS],
# [3:YYLEX_ACTION], [4:LEXER_BODY], [5:PARSER_ACTION], [6:STYPE], # [3:YYLEX_ACTION], [4:LEXER_BODY], [5:PARSER_ACTION], [6:VALUE_TYPE],
# [7:POSITION_TYPE], [8:LOCATION_TYPE]) # [7:POSITION_TYPE], [8:LOCATION_TYPE])
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
# Check that a mininal parser with DIRECTIVES and a "%code lexer". # Check that a mininal parser with DIRECTIVES and a "%code lexer".
@@ -742,14 +742,14 @@ AT_CHECK([[grep -q 'super("Test Thread"); if (true) throw new InterruptedExcepti
AT_CLEANUP AT_CLEANUP
# --------------------------------------------- # # ------------------------------------------ #
# Java stype, position_class and location_class # # Java value, position, and location types. #
# --------------------------------------------- # # ------------------------------------------ #
AT_SETUP([Java stype, position_class and location_class]) AT_SETUP([Java value, position, and location types])
AT_CHECK_JAVA_MINIMAL([[ AT_CHECK_JAVA_MINIMAL([[
%define stype "java.awt.Color" %define api.value.type "java.awt.Color"
%type<java.awt.Color> start; %type<java.awt.Color> start;
%define api.location.type "MyLoc" %define api.location.type "MyLoc"
%define api.position.type "MyPos" %define api.position.type "MyPos"
@@ -759,7 +759,7 @@ AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Position']], [1], [ignore])
AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Location']], [1], [ignore]) AT_CHECK([[$EGREP -v ' */?\*' YYParser.java | grep 'Location']], [1], [ignore])
AT_CHECK_JAVA_MINIMAL_W_LEXER([[ AT_CHECK_JAVA_MINIMAL_W_LEXER([[
%define stype "java.awt.Color" %define api.value.type "java.awt.Color"
%type<java.awt.Color> start; %type<java.awt.Color> start;
%define api.location.type "MyLoc" %define api.location.type "MyLoc"
%define api.position.type "MyPos" %define api.position.type "MyPos"