mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
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:
20
NEWS
20
NEWS
@@ -30,10 +30,18 @@ GNU Bison NEWS
|
||||
@code{YYTOKENTYPE}, @code{yytokentype}, @code{YYSTYPE}, @code{YYLTYPE},
|
||||
etc.
|
||||
|
||||
The following variables have been renamed for consistency. Backward
|
||||
compatibility is ensured, but upgrading is recommended.
|
||||
The following variables, mostly related to parsers in Java, have been
|
||||
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
|
||||
|
||||
@@ -118,6 +126,8 @@ GNU Bison NEWS
|
||||
until it sees the '='. So we notate the two possible reductions to
|
||||
indicate that each conflicts in one rule.
|
||||
|
||||
This feature needs user feedback, and might evolve in the future.
|
||||
|
||||
*** C++: Actual token constructors
|
||||
|
||||
When variants and token constructors are enabled, in addition to the
|
||||
@@ -144,6 +154,10 @@ GNU Bison NEWS
|
||||
":" return yy::parser::symbol_type (’:’);
|
||||
<<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
|
||||
|
||||
If your application requires C++11 and you don't use symbol constructors,
|
||||
|
||||
@@ -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
|
||||
# qualifiers/annotations.
|
||||
b4_percent_define_default([[public]], [[false]])
|
||||
b4_percent_define_default([[abstract]], [[false]])
|
||||
b4_percent_define_default([[final]], [[false]])
|
||||
b4_percent_define_default([[api.parser.abstract]], [[false]])
|
||||
b4_percent_define_default([[api.parser.final]], [[false]])
|
||||
b4_percent_define_default([[api.parser.public]], [[false]])
|
||||
|
||||
m4_define([b4_parser_class_declaration],
|
||||
[b4_percent_define_get3([annotations], [], [ ])dnl
|
||||
b4_percent_define_flag_if([public], [public ])dnl
|
||||
b4_percent_define_flag_if([abstract], [abstract ])dnl
|
||||
b4_percent_define_flag_if([final], [final ])dnl
|
||||
[b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
|
||||
b4_percent_define_flag_if([api.parser.public], [public ])dnl
|
||||
b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
|
||||
b4_percent_define_flag_if([api.parser.final], [final ])dnl
|
||||
[class ]b4_parser_class[]dnl
|
||||
b4_percent_define_get3([extends], [ extends ])dnl
|
||||
b4_percent_define_get3([implements], [ implements ])])
|
||||
b4_percent_define_get3([api.parser.extends], [ extends ])dnl
|
||||
b4_percent_define_get3([api.parser.implements], [ implements ])])
|
||||
|
||||
|
||||
# b4_lexer_if(TRUE, FALSE)
|
||||
|
||||
@@ -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
|
||||
# qualifiers/annotations.
|
||||
b4_percent_define_default([[public]], [[false]])
|
||||
b4_percent_define_default([[abstract]], [[false]])
|
||||
b4_percent_define_default([[final]], [[false]])
|
||||
b4_percent_define_default([[strictfp]], [[false]])
|
||||
b4_percent_define_default([[api.parser.abstract]], [[false]])
|
||||
b4_percent_define_default([[api.parser.final]], [[false]])
|
||||
b4_percent_define_default([[api.parser.public]], [[false]])
|
||||
b4_percent_define_default([[api.parser.strictfp]], [[false]])
|
||||
|
||||
m4_define([b4_parser_class_declaration],
|
||||
[b4_percent_define_get3([annotations], [], [ ])dnl
|
||||
b4_percent_define_flag_if([public], [public ])dnl
|
||||
b4_percent_define_flag_if([abstract], [abstract ])dnl
|
||||
b4_percent_define_flag_if([final], [final ])dnl
|
||||
b4_percent_define_flag_if([strictfp], [strictfp ])dnl
|
||||
[b4_percent_define_get3([api.parser.annotations], [], [ ])dnl
|
||||
b4_percent_define_flag_if([api.parser.public], [public ])dnl
|
||||
b4_percent_define_flag_if([api.parser.abstract], [abstract ])dnl
|
||||
b4_percent_define_flag_if([api.parser.final], [final ])dnl
|
||||
b4_percent_define_flag_if([api.parser.strictfp], [strictfp ])dnl
|
||||
[class ]b4_parser_class[]dnl
|
||||
b4_percent_define_get3([extends], [ extends ])dnl
|
||||
b4_percent_define_get3([implements], [ implements ])])
|
||||
b4_percent_define_get3([api.parser.extends], [ extends ])dnl
|
||||
b4_percent_define_get3([api.parser.implements], [ implements ])])
|
||||
|
||||
|
||||
# b4_lexer_if(TRUE, FALSE)
|
||||
|
||||
@@ -10979,11 +10979,6 @@ complete and accurate documentation.
|
||||
|
||||
@node 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
|
||||
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
|
||||
@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
|
||||
@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.
|
||||
|
||||
By default, the parser class has package visibility. A declaration
|
||||
@samp{%define public} will change to public visibility. Remember that,
|
||||
according to the Java language specification, the name of the @file{.java}
|
||||
file should match the name of the class in this case. Similarly, you can
|
||||
use @code{abstract}, @code{final} and @code{strictfp} with the
|
||||
@code{%define} declaration to add other modifiers to the parser class.
|
||||
A single @samp{%define annotations @{@var{annotations}@}} directive can
|
||||
be used to add any number of annotations to the parser class.
|
||||
@samp{%define api.parser.public} will change to public visibility. Remember
|
||||
that, according to the Java language specification, the name of the
|
||||
@file{.java} file should match the name of the class in this case.
|
||||
Similarly, you can use @code{api.parser.abstract}, @code{api.parser.final}
|
||||
and @code{api.parser.strictfp} with the @code{%define} declaration to add
|
||||
other modifiers to the parser class. A single @samp{%define
|
||||
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
|
||||
@samp{%define package} directive. The superclass and the implemented
|
||||
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
|
||||
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}.
|
||||
@end deffn
|
||||
|
||||
@deffn {Directive} {%define abstract}
|
||||
@deffn {Directive} {%define api.parser.abstract}
|
||||
Whether the parser class is declared @code{abstract}. Default is false.
|
||||
@xref{Java Bison Interface}.
|
||||
@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.
|
||||
@xref{Java Bison Interface}.
|
||||
@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.
|
||||
@xref{Java Bison Interface}.
|
||||
@end deffn
|
||||
|
||||
@deffn {Directive} {%define final}
|
||||
@deffn {Directive} {%define api.parser.final}
|
||||
Whether the parser class is declared @code{final}. Default is false.
|
||||
@xref{Java Bison Interface}.
|
||||
@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.
|
||||
Default is none.
|
||||
@xref{Java Bison Interface}.
|
||||
@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}@}
|
||||
The exceptions thrown by @code{%code init} from the parser class
|
||||
constructor. Default is none.
|
||||
@@ -12850,11 +12856,6 @@ The package to put the parser class in. Default is none.
|
||||
@xref{Java Bison Interface}.
|
||||
@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}@}
|
||||
The name of the class used for positions. This class must be supplied by
|
||||
the user. Default is @code{Position}.
|
||||
@@ -12862,21 +12863,11 @@ Formerly named @code{position_type}.
|
||||
@xref{Java Location Values}.
|
||||
@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}@}
|
||||
The base type of semantic values. Default is @code{Object}.
|
||||
@xref{Java Semantic Values}.
|
||||
@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}@}
|
||||
The exceptions thrown by user-supplied parser actions and
|
||||
@code{%initial-action}, a comma-separated list. Default is none.
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
%language "D"
|
||||
|
||||
%define api.parser.class {Calc}
|
||||
%define public
|
||||
|
||||
%define parse.error verbose
|
||||
|
||||
%code imports {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
%language "Java"
|
||||
|
||||
%define api.parser.class {Calc}
|
||||
%define public
|
||||
%define api.parser.public
|
||||
|
||||
%define parse.error verbose
|
||||
%locations
|
||||
|
||||
@@ -456,6 +456,13 @@ muscle_percent_variable_update (char const *variable, location variable_loc,
|
||||
{ "stype", "api.value.type", -1 },
|
||||
{ "variant=", "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, }
|
||||
};
|
||||
|
||||
|
||||
@@ -1833,14 +1833,14 @@ AT_SETUP([["%define" Boolean variables]])
|
||||
|
||||
AT_DATA([Input.y],
|
||||
[[%language "Java"
|
||||
%define public maybe
|
||||
%define api.parser.class {Input}
|
||||
%define api.parser.public {maybe}
|
||||
%%
|
||||
start: %empty;
|
||||
]])
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user