java/d: rename some %define variables for consistency

See 890ee8a1fd and
https://lists.gnu.org/archive/html/bison-patches/2019-01/msg00024.html.

* data/skeletons/d.m4, data/skeletons/java.m4
(abstract, annotations, extends, final, implements, public, strictfp):
Rename as...
(api.parser.abstract, api.parser.annotations, api.parser.extends)
(api.parser.final, api.parser.implements, api.parser.public)
(api.parser.strictfp):
these.

* src/muscle-tab.c (muscle_percent_variable_update): Ensure backward
compatibility.

* doc/bison.texi, examples/d/calc.y, examples/java/Calc.y,
tests/input.at: Adjust.
This commit is contained in:
Akim Demaille
2018-12-31 09:29:56 +01:00
parent 230d6c5160
commit c0c45cfa38
8 changed files with 76 additions and 66 deletions

20
NEWS
View File

@@ -30,10 +30,18 @@ GNU Bison NEWS
@code{YYTOKENTYPE}, @code{yytokentype}, @code{YYSTYPE}, @code{YYLTYPE}, @code{YYTOKENTYPE}, @code{yytokentype}, @code{YYSTYPE}, @code{YYLTYPE},
etc. etc.
The following variables have been renamed for consistency. Backward The following variables, mostly related to parsers in Java, have been
compatibility is ensured, but upgrading is recommended. renamed for consistency. Backward compatibility is ensured, but upgrading
is recommended.
parser_class_name -> api.parser.class abstract -> api.parser.abstract
annotations -> api.parser.annotations
extends -> api.parser.extends
final -> api.parser.final
implements -> api.parser.implements
parser_class_name -> api.parser.class
public -> api.parser.public
strictfp -> api.parser.strictfp
** New features ** New features
@@ -118,6 +126,8 @@ GNU Bison NEWS
until it sees the '='. So we notate the two possible reductions to until it sees the '='. So we notate the two possible reductions to
indicate that each conflicts in one rule. indicate that each conflicts in one rule.
This feature needs user feedback, and might evolve in the future.
*** C++: Actual token constructors *** C++: Actual token constructors
When variants and token constructors are enabled, in addition to the When variants and token constructors are enabled, in addition to the
@@ -144,6 +154,10 @@ GNU Bison NEWS
":" return yy::parser::symbol_type (:); ":" return yy::parser::symbol_type (:);
<<EOF>> return yy::parser::symbol_type (0); <<EOF>> return yy::parser::symbol_type (0);
Correct matching between token types and value types is checked via
'assert'. For instance, 'symbol_type (ID, 42)' would abort (while
'make_ID (42)' would not even compile).
*** C++: Variadic emplace *** C++: Variadic emplace
If your application requires C++11 and you don't use symbol constructors, If your application requires C++11 and you don't use symbol constructors,

View File

@@ -50,18 +50,18 @@ m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
# --------------------------- # ---------------------------
# The declaration of the parser class ("class YYParser"), with all its # The declaration of the parser class ("class YYParser"), with all its
# qualifiers/annotations. # qualifiers/annotations.
b4_percent_define_default([[public]], [[false]]) b4_percent_define_default([[api.parser.abstract]], [[false]])
b4_percent_define_default([[abstract]], [[false]]) b4_percent_define_default([[api.parser.final]], [[false]])
b4_percent_define_default([[final]], [[false]]) b4_percent_define_default([[api.parser.public]], [[false]])
m4_define([b4_parser_class_declaration], m4_define([b4_parser_class_declaration],
[b4_percent_define_get3([annotations], [], [ ])dnl [b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
b4_percent_define_flag_if([public], [public ])dnl b4_percent_define_flag_if([api.parser.public], [public ])dnl
b4_percent_define_flag_if([abstract], [abstract ])dnl b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
b4_percent_define_flag_if([final], [final ])dnl b4_percent_define_flag_if([api.parser.final], [final ])dnl
[class ]b4_parser_class[]dnl [class ]b4_parser_class[]dnl
b4_percent_define_get3([extends], [ extends ])dnl b4_percent_define_get3([api.parser.extends], [ extends ])dnl
b4_percent_define_get3([implements], [ implements ])]) b4_percent_define_get3([api.parser.implements], [ implements ])])
# b4_lexer_if(TRUE, FALSE) # b4_lexer_if(TRUE, FALSE)

View File

@@ -46,20 +46,20 @@ m4_define([b4_flag_value], [b4_flag_if([$1], [true], [false])])
# --------------------------- # ---------------------------
# The declaration of the parser class ("class YYParser"), with all its # The declaration of the parser class ("class YYParser"), with all its
# qualifiers/annotations. # qualifiers/annotations.
b4_percent_define_default([[public]], [[false]]) b4_percent_define_default([[api.parser.abstract]], [[false]])
b4_percent_define_default([[abstract]], [[false]]) b4_percent_define_default([[api.parser.final]], [[false]])
b4_percent_define_default([[final]], [[false]]) b4_percent_define_default([[api.parser.public]], [[false]])
b4_percent_define_default([[strictfp]], [[false]]) b4_percent_define_default([[api.parser.strictfp]], [[false]])
m4_define([b4_parser_class_declaration], m4_define([b4_parser_class_declaration],
[b4_percent_define_get3([annotations], [], [ ])dnl [b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
b4_percent_define_flag_if([public], [public ])dnl b4_percent_define_flag_if([api.parser.public], [public ])dnl
b4_percent_define_flag_if([abstract], [abstract ])dnl b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
b4_percent_define_flag_if([final], [final ])dnl b4_percent_define_flag_if([api.parser.final], [final ])dnl
b4_percent_define_flag_if([strictfp], [strictfp ])dnl b4_percent_define_flag_if([api.parser.strictfp], [strictfp ])dnl
[class ]b4_parser_class[]dnl [class ]b4_parser_class[]dnl
b4_percent_define_get3([extends], [ extends ])dnl b4_percent_define_get3([api.parser.extends], [ extends ])dnl
b4_percent_define_get3([implements], [ implements ])]) b4_percent_define_get3([api.parser.implements], [ implements ])])
# b4_lexer_if(TRUE, FALSE) # b4_lexer_if(TRUE, FALSE)

View File

@@ -10979,11 +10979,6 @@ complete and accurate documentation.
@node C++ Parser Interface @node C++ Parser Interface
@subsection C++ Parser Interface @subsection C++ Parser Interface
@c - define api.parser.class
@c - Ctor
@c - parse, error, set_debug_level, debug_level, set_debug_stream,
@c debug_stream.
@c - Reporting errors
The output files @file{@var{file}.hh} and @file{@var{file}.cc} declare and The output files @file{@var{file}.hh} and @file{@var{file}.cc} declare and
define the parser class in the namespace @code{yy}. The class name defaults define the parser class in the namespace @code{yy}. The class name defaults
@@ -12359,11 +12354,6 @@ properly, the position class should override the @code{equals} and
@node Java Parser Interface @node Java Parser Interface
@subsection Java Parser Interface @subsection Java Parser Interface
@c - define api.parser.class
@c - Ctor
@c - parse, error, set_debug_level, debug_level, set_debug_stream,
@c debug_stream.
@c - Reporting errors
The name of the generated parser class defaults to @code{YYParser}. The The name of the generated parser class defaults to @code{YYParser}. The
@code{YY} prefix may be changed using the @samp{%define api.prefix}. @code{YY} prefix may be changed using the @samp{%define api.prefix}.
@@ -12371,18 +12361,19 @@ Alternatively, use @samp{%define api.parser.class @{@var{name}@}} to give a
custom name to the class. The interface of this class is detailed below. custom name to the class. The interface of this class is detailed below.
By default, the parser class has package visibility. A declaration By default, the parser class has package visibility. A declaration
@samp{%define public} will change to public visibility. Remember that, @samp{%define api.parser.public} will change to public visibility. Remember
according to the Java language specification, the name of the @file{.java} that, according to the Java language specification, the name of the
file should match the name of the class in this case. Similarly, you can @file{.java} file should match the name of the class in this case.
use @code{abstract}, @code{final} and @code{strictfp} with the Similarly, you can use @code{api.parser.abstract}, @code{api.parser.final}
@code{%define} declaration to add other modifiers to the parser class. and @code{api.parser.strictfp} with the @code{%define} declaration to add
A single @samp{%define annotations @{@var{annotations}@}} directive can other modifiers to the parser class. A single @samp{%define
be used to add any number of annotations to the parser class. api.parser.annotations @{@var{annotations}@}} directive can be used to add
any number of annotations to the parser class.
The Java package name of the parser class can be specified using the The Java package name of the parser class can be specified using the
@samp{%define package} directive. The superclass and the implemented @samp{%define package} directive. The superclass and the implemented
interfaces of the parser class can be specified with the @code{%define interfaces of the parser class can be specified with the @code{%define
extends} and @samp{%define implements} directives. api.parser.extends} and @samp{%define api.parser.implements} directives.
The parser class defines an inner class, @code{Location}, that is used The parser class defines an inner class, @code{Location}, that is used
for location tracking (see @ref{Java Location Values}), and a inner for location tracking (see @ref{Java Location Values}), and a inner
@@ -12799,32 +12790,47 @@ The prefix of the parser class name @code{@var{prefix}Parser} if
@xref{Java Bison Interface}. @xref{Java Bison Interface}.
@end deffn @end deffn
@deffn {Directive} {%define abstract} @deffn {Directive} {%define api.parser.abstract}
Whether the parser class is declared @code{abstract}. Default is false. Whether the parser class is declared @code{abstract}. Default is false.
@xref{Java Bison Interface}. @xref{Java Bison Interface}.
@end deffn @end deffn
@deffn {Directive} {%define annotations} @{@var{annotations}@} @deffn {Directive} {%define api.parser.annotations} @{@var{annotations}@}
The Java annotations for the parser class. Default is none. The Java annotations for the parser class. Default is none.
@xref{Java Bison Interface}. @xref{Java Bison Interface}.
@end deffn @end deffn
@deffn {Directive} {%define extends} @{@var{superclass}@} @deffn {Directive} {%define api.parser.class} @{@var{name}@}
The name of the parser class. Default is @code{YYParser} or
@code{@var{api.prefix}Parser}. @xref{Java Bison Interface}.
@end deffn
@deffn {Directive} {%define api.parser.extends} @{@var{superclass}@}
The superclass of the parser class. Default is none. The superclass of the parser class. Default is none.
@xref{Java Bison Interface}. @xref{Java Bison Interface}.
@end deffn @end deffn
@deffn {Directive} {%define final} @deffn {Directive} {%define api.parser.final}
Whether the parser class is declared @code{final}. Default is false. Whether the parser class is declared @code{final}. Default is false.
@xref{Java Bison Interface}. @xref{Java Bison Interface}.
@end deffn @end deffn
@deffn {Directive} {%define implements} @{@var{interfaces}@} @deffn {Directive} {%define api.parser.implements} @{@var{interfaces}@}
The implemented interfaces of the parser class, a comma-separated list. The implemented interfaces of the parser class, a comma-separated list.
Default is none. Default is none.
@xref{Java Bison Interface}. @xref{Java Bison Interface}.
@end deffn @end deffn
@deffn {Directive} {%define api.parser.public}
Whether the parser class is declared @code{public}. Default is false.
@xref{Java Bison Interface}.
@end deffn
@deffn {Directive} {%define api.parser.strictfp}
Whether the parser class is declared @code{strictfp}. Default is false.
@xref{Java Bison Interface}.
@end deffn
@deffn {Directive} {%define init_throws} @{@var{exceptions}@} @deffn {Directive} {%define init_throws} @{@var{exceptions}@}
The exceptions thrown by @code{%code init} from the parser class The exceptions thrown by @code{%code init} from the parser class
constructor. Default is none. constructor. Default is none.
@@ -12850,11 +12856,6 @@ The package to put the parser class in. Default is none.
@xref{Java Bison Interface}. @xref{Java Bison Interface}.
@end deffn @end deffn
@deffn {Directive} {%define api.parser.class} @{@var{name}@}
The name of the parser class. Default is @code{YYParser} or
@code{@var{api.prefix}Parser}. @xref{Java Bison Interface}.
@end deffn
@deffn {Directive} {%define api.position.type} @{@var{class}@} @deffn {Directive} {%define api.position.type} @{@var{class}@}
The name of the class used for positions. This class must be supplied by The name of the class used for positions. This class must be supplied by
the user. Default is @code{Position}. the user. Default is @code{Position}.
@@ -12862,21 +12863,11 @@ Formerly named @code{position_type}.
@xref{Java Location Values}. @xref{Java Location Values}.
@end deffn @end deffn
@deffn {Directive} {%define public}
Whether the parser class is declared @code{public}. Default is false.
@xref{Java Bison Interface}.
@end deffn
@deffn {Directive} {%define api.value.type} @{@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
@deffn {Directive} {%define strictfp}
Whether the parser class is declared @code{strictfp}. Default is false.
@xref{Java Bison Interface}.
@end deffn
@deffn {Directive} {%define throws} @{@var{exceptions}@} @deffn {Directive} {%define throws} @{@var{exceptions}@}
The exceptions thrown by user-supplied parser actions and The exceptions thrown by user-supplied parser actions and
@code{%initial-action}, a comma-separated list. Default is none. @code{%initial-action}, a comma-separated list. Default is none.

View File

@@ -1,8 +1,6 @@
%language "D" %language "D"
%define api.parser.class {Calc} %define api.parser.class {Calc}
%define public
%define parse.error verbose %define parse.error verbose
%code imports { %code imports {

View File

@@ -1,7 +1,7 @@
%language "Java" %language "Java"
%define api.parser.class {Calc} %define api.parser.class {Calc}
%define public %define api.parser.public
%define parse.error verbose %define parse.error verbose
%locations %locations

View File

@@ -456,6 +456,13 @@ muscle_percent_variable_update (char const *variable, location variable_loc,
{ "stype", "api.value.type", -1 }, { "stype", "api.value.type", -1 },
{ "variant=", "api.value.type=variant", -1 }, { "variant=", "api.value.type=variant", -1 },
{ "variant=true", "api.value.type=variant", -1 }, { "variant=true", "api.value.type=variant", -1 },
{ "abstract", "api.parser.abstract", muscle_keyword },
{ "annotations", "api.parser.annotations", muscle_code },
{ "extends", "api.parser.extends", muscle_keyword },
{ "final", "api.parser.final", muscle_keyword },
{ "implements", "api.parser.implements", muscle_keyword },
{ "public", "api.parser.public", muscle_keyword },
{ "strictfp", "api.parser.strictfp", muscle_keyword },
{ NULL, NULL, -1, } { NULL, NULL, -1, }
}; };

View File

@@ -1833,14 +1833,14 @@ AT_SETUP([["%define" Boolean variables]])
AT_DATA([Input.y], AT_DATA([Input.y],
[[%language "Java" [[%language "Java"
%define public maybe
%define api.parser.class {Input} %define api.parser.class {Input}
%define api.parser.public {maybe}
%% %%
start: %empty; start: %empty;
]]) ]])
AT_BISON_CHECK([[Input.y]], [1], [], AT_BISON_CHECK([[Input.y]], [1], [],
[[Input.y:2.9-14: error: invalid value for %define Boolean variable 'public' [[Input.y:3.9-25: error: invalid value for %define Boolean variable 'api.parser.public'
]]) ]])
AT_CLEANUP AT_CLEANUP