diff --git a/NEWS b/NEWS index c2a64bdf..50e7aa02 100644 --- a/NEWS +++ b/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 (’:’); <> 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, diff --git a/data/skeletons/d.m4 b/data/skeletons/d.m4 index c9444e15..6183eada 100644 --- a/data/skeletons/d.m4 +++ b/data/skeletons/d.m4 @@ -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) diff --git a/data/skeletons/java.m4 b/data/skeletons/java.m4 index a751e895..7c88a682 100644 --- a/data/skeletons/java.m4 +++ b/data/skeletons/java.m4 @@ -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) diff --git a/doc/bison.texi b/doc/bison.texi index 859e78bf..1f5ae853 100644 --- a/doc/bison.texi +++ b/doc/bison.texi @@ -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. diff --git a/examples/d/calc.y b/examples/d/calc.y index 9c1b11f3..a54e82ed 100644 --- a/examples/d/calc.y +++ b/examples/d/calc.y @@ -1,8 +1,6 @@ %language "D" %define api.parser.class {Calc} -%define public - %define parse.error verbose %code imports { diff --git a/examples/java/Calc.y b/examples/java/Calc.y index c84f4507..5da43269 100644 --- a/examples/java/Calc.y +++ b/examples/java/Calc.y @@ -1,7 +1,7 @@ %language "Java" %define api.parser.class {Calc} -%define public +%define api.parser.public %define parse.error verbose %locations diff --git a/src/muscle-tab.c b/src/muscle-tab.c index 186b228d..26b4b3e5 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -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, } }; diff --git a/tests/input.at b/tests/input.at index 5f2dd58e..f39ee269 100644 --- a/tests/input.at +++ b/tests/input.at @@ -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