bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

java/d: rename some %define variables for consistency (was: RFC: rename


From: Akim Demaille
Subject: java/d: rename some %define variables for consistency (was: RFC: rename parser_class_name as api.parser.class)
Date: Sat, 5 Jan 2019 14:55:50 +0100


> Le 4 janv. 2019 à 07:53, Akim Demaille <address@hidden> a écrit :
> 
>> Le 3 janv. 2019 à 18:45, Akim Demaille <address@hidden> a écrit :
>> 
>>> Le 2 janv. 2019 à 08:13, Akim Demaille <address@hidden> a écrit :
>>> 
>>> We've never finished cleaning up the muscle names.  If D really makes it 
>>> into Bison, it would be sad that they use such inconsistent names, so let's 
>>> finish this soon.
>>> 
>>> I'm not very happy with api.parser.class, if someone has a better idea, 
>>> please step forward!  I have avoided api.parser.type, because 
>>> api.value.type and api.location.type are not about declaring a type, but 
>>> using a type.  I think that api.parser.class.name is too long.  But we do 
>>> have api.value.union.name already.
>>> 
>>> So api.parser.class.name could be better, but I'd be happy to have opinions.
>> 
>> Installed.
> 
> There's a bunch of similar %define variables that we should rename: public, 
> extends, etc.  They come from the Java skeleton.  What do you think it should 
> be:
> 
> public -> api.parser.public  or api.parser.class.public
> extends
> implements
> abstract
> final
> strictfp
> annotations


commit c0c45cfa382678a43dbc5a2b328e11c6bdb91eb2
Author: Akim Demaille <address@hidden>
Date:   Mon Dec 31 09:29:56 2018 +0100

    java/d: rename some %define variables for consistency
    
    See 890ee8a1fd288b3cc1c21c49ea0ece696ef40565 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.

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.
-
-    parser_class_name          -> api.parser.class
+  The following variables, mostly related to parsers in Java, have been
+  renamed for consistency.  Backward compatibility is ensured, but upgrading
+  is recommended.
+
+    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,
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
address@hidden - define api.parser.class
address@hidden - Ctor
address@hidden - parse, error, set_debug_level, debug_level, set_debug_stream,
address@hidden   debug_stream.
address@hidden - Reporting errors
 
 The output files @address@hidden and @address@hidden 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
address@hidden - define api.parser.class
address@hidden - Ctor
address@hidden - parse, error, set_debug_level, debug_level, set_debug_stream,
address@hidden   debug_stream.
address@hidden - 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 
@address@hidden@}} 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
address@hidden 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
address@hidden declaration to add other modifiers to the parser class.
-A single @samp{%define annotations @address@hidden@}} directive can
-be used to add any number of annotations to the parser class.
address@hidden api.parser.public} will change to public visibility.  Remember
+that, according to the Java language specification, the name of the
address@hidden 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 @address@hidden@}} 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 @address@hidden if
 @xref{Java Bison Interface}.
 @end deffn
 
address@hidden {Directive} {%define abstract}
address@hidden {Directive} {%define api.parser.abstract}
 Whether the parser class is declared @code{abstract}.  Default is false.
 @xref{Java Bison Interface}.
 @end deffn
 
address@hidden {Directive} {%define annotations} @address@hidden@}
address@hidden {Directive} {%define api.parser.annotations} @address@hidden@}
 The Java annotations for the parser class.  Default is none.
 @xref{Java Bison Interface}.
 @end deffn
 
address@hidden {Directive} {%define extends} @address@hidden@}
address@hidden {Directive} {%define api.parser.class} @address@hidden@}
+The name of the parser class.  Default is @code{YYParser} or
address@hidden@var{api.prefix}Parser}.  @xref{Java Bison Interface}.
address@hidden deffn
+
address@hidden {Directive} {%define api.parser.extends} @address@hidden@}
 The superclass of the parser class.  Default is none.
 @xref{Java Bison Interface}.
 @end deffn
 
address@hidden {Directive} {%define final}
address@hidden {Directive} {%define api.parser.final}
 Whether the parser class is declared @code{final}.  Default is false.
 @xref{Java Bison Interface}.
 @end deffn
 
address@hidden {Directive} {%define implements} @address@hidden@}
address@hidden {Directive} {%define api.parser.implements} @address@hidden@}
 The implemented interfaces of the parser class, a comma-separated list.
 Default is none.
 @xref{Java Bison Interface}.
 @end deffn
 
address@hidden {Directive} {%define api.parser.public}
+Whether the parser class is declared @code{public}.  Default is false.
address@hidden Bison Interface}.
address@hidden deffn
+
address@hidden {Directive} {%define api.parser.strictfp}
+Whether the parser class is declared @code{strictfp}.  Default is false.
address@hidden Bison Interface}.
address@hidden deffn
+
 @deffn {Directive} {%define init_throws} @address@hidden@}
 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
 
address@hidden {Directive} {%define api.parser.class} @address@hidden@}
-The name of the parser class.  Default is @code{YYParser} or
address@hidden@var{api.prefix}Parser}.  @xref{Java Bison Interface}.
address@hidden deffn
-
 @deffn {Directive} {%define api.position.type} @address@hidden@}
 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
 
address@hidden {Directive} {%define public}
-Whether the parser class is declared @code{public}.  Default is false.
address@hidden Bison Interface}.
address@hidden deffn
-
 @deffn {Directive} {%define api.value.type} @address@hidden@}
 The base type of semantic values.  Default is @code{Object}.
 @xref{Java Semantic Values}.
 @end deffn
 
address@hidden {Directive} {%define strictfp}
-Whether the parser class is declared @code{strictfp}.  Default is false.
address@hidden Bison Interface}.
address@hidden deffn
-
 @deffn {Directive} {%define throws} @address@hidden@}
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]