bison-patches
[Top][All Lists]
Advanced

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

Re: [PATCH 0/3] RFC: update %define variable diagnostics


From: Akim Demaille
Subject: Re: [PATCH 0/3] RFC: update %define variable diagnostics
Date: Wed, 26 Dec 2012 10:32:52 +0100

Le 26 déc. 2012 à 10:24, Akim Demaille <address@hidden> a écrit :

> 
> Le 21 déc. 2012 à 16:13, Akim Demaille <address@hidden> a écrit :
> 
>> Pushed in branch api.value.type.c:
>> 
>> Akim Demaille (3):
>> diagnostics: factor the deprecated directive message
>> diagnostics: treat obsolete %define variable names as obsolete
>>   directives
>> %define variables: support value changes in deprecation
> 
> Pushed in master.

Then these two.

commit ae8880deec6ffba6a71652bf98ffcf62d602f82b
Author: Akim Demaille <address@hidden>
Date:   Sun Dec 23 12:47:31 2012 +0100

    doc: update variant usage
    
    * doc/bison.texi, examples/variant.yy: Use "%define api.value.type variant",
    instead of "%define variant".

diff --git a/doc/bison.texi b/doc/bison.texi
index c1cafee..f028ebf 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -5744,6 +5744,26 @@ introduced in Bison 2.8
 @c api.token.prefix
 
 
address@hidden ================================================== api.value.type
address@hidden %define api.value.type variant
address@hidden %define api.value.type variant
+
address@hidden @bullet
address@hidden Language(s):
+C++
+
address@hidden Purpose:
+Request variant-based semantic values.
address@hidden Variants}.
+
address@hidden FIXME: @item Accepted Values:
address@hidden FIXME: Boolean.
+
address@hidden @item Default Value:
address@hidden @code{false}
+@ @end itemize
address@hidden api.value.type
+
 @c ================================================== lr.default-reduction
 
 @item lr.default-reduction
@@ -5891,29 +5911,8 @@ compiled.
 @item Default Value: @code{false}
 @end itemize
 @c parse.trace
-
address@hidden ================================================== variant
address@hidden variant
address@hidden %define variant
-
address@hidden @bullet
address@hidden Language(s):
-C++
-
address@hidden Purpose:
-Request variant-based semantic values.
address@hidden Variants}.
-
address@hidden Accepted Values:
-Boolean.
-
address@hidden Default Value:
address@hidden
address@hidden itemize
address@hidden variant
 @end table
 
-
 @node %code Summary
 @subsection %code Summary
 @findex %code
@@ -10115,10 +10114,9 @@ Symbols}.
 @node C++ Variants
 @subsubsection C++ Variants
 
-Starting with version 2.6, Bison provides a @emph{variant} based
-implementation of semantic values for C++.  This alleviates all the
-limitations reported in the previous section, and in particular, object
-types can be used without pointers.
+Bison provides a @emph{variant} based implementation of semantic values for
+C++.  This alleviates all the limitations reported in the previous section,
+and in particular, object types can be used without pointers.
 
 To enable variant-based semantic values, set @code{%define} variable
 @code{variant} (@pxref{%define Summary,, variant}).  Once this defined,
@@ -10546,7 +10544,7 @@ or
 @node Complete Symbols
 @subsubsection Complete Symbols
 
-If you specified both @code{%define variant} and
+If you specified both @code{%define api.value.type variant} and
 @code{%define api.token.constructor},
 the @code{parser} class also defines the class @code{parser::symbol_type}
 which defines a @emph{complete} symbol, aggregating its type (i.e., the
@@ -10810,7 +10808,7 @@ the grammar for.
 
 @noindent
 @findex %define api.token.constructor
address@hidden %define variant
address@hidden %define api.value.type variant
 This example will use genuine C++ objects as semantic values, therefore, we
 require the variant-based interface.  To make sure we properly use it, we
 enable assertions.  To fully benefit from type-safety and more natural
@@ -10819,8 +10817,8 @@ definition of ``symbol'', we enable 
@code{api.token.constructor}.
 @comment file: calc++-parser.yy
 @example
 %define api.token.constructor
+%define api.value.type variant
 %define parse.assert
-%define variant
 @end example
 
 @noindent
diff --git a/examples/variant.yy b/examples/variant.yy
index 25f476a..33db351 100644
--- a/examples/variant.yy
+++ b/examples/variant.yy
@@ -19,8 +19,8 @@
 %skeleton "lalr1.cc"
 %defines
 %define api.token.constructor
+%define api.value.type variant
 %define parse.assert
-%define variant
 %locations
 
 %code requires // *.hh

commit 1a06f28efc71127635056174ed2923a7847342fb
Author: Akim Demaille <address@hidden>
Date:   Sun Dec 23 10:52:23 2012 +0100

    tests: check the "%define variant" is deprecated.
    
    * tests/input.at: Rename some AT_SETUP to avoid that
    AT_SETUP_STRIP thinks they contain %define directives.
    ("%define" backward compatibility): Merge tests together
    to speed up the test suite, and to make maintenance easier
    (multiple AT_CHECK means multiple runs of the test suite to
    be sure to have updated all the error messages).
    Check the "%define variant" is properly obsoleted.

diff --git a/tests/input.at b/tests/input.at
index 50af0a8..f60eaec 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -1270,7 +1270,7 @@ AT_CLEANUP
 ## %define Boolean variables.  ##
 ## --------------------------- ##
 
-AT_SETUP([[%define Boolean variables]])
+AT_SETUP([["%define" Boolean variables]])
 
 AT_DATA([Input.y],
 [[%language "Java"
@@ -1290,7 +1290,11 @@ AT_CLEANUP
 ## %define enum variables.  ##
 ## ------------------------ ##
 
-AT_SETUP([[%define enum variables]])
+AT_SETUP([["%define" enum variables]])
+
+# Check errors from the front-end, and the back-end.  Since the
+# front-end quits before calling the back-end, these tests cannot be
+# fused.
 
 # Front-end.
 AT_DATA([[input.y]],
@@ -1298,22 +1302,25 @@ AT_DATA([[input.y]],
 %%
 start: ;
 ]])
-AT_BISON_CHECK([[input.y]], [[1]], [[]],
+AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
 [[input.y:1.9-28: error: invalid value for %define variable 
'lr.default-reduction': 'bogus'
+ %define lr.default-reduction bogus
+         ^^^^^^^^^^^^^^^^^^^^
 input.y:1.9-28:     accepted value: 'most'
 input.y:1.9-28:     accepted value: 'consistent'
 input.y:1.9-28:     accepted value: 'accepting'
 ]])
 
 # Back-end.
-# FIXME: these should be indented, but we shouldn't mess with the m4 yet
 AT_DATA([[input.y]],
 [[%define api.push-pull neither
 %%
 start: ;
 ]])
-AT_BISON_CHECK([[input.y]], [1], [],
+AT_BISON_CHECK([[-fcaret input.y]], [[1]], [[]],
 [[input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 
'neither'
+ %define api.push-pull neither
+         ^^^^^^^^^^^^^
 input.y:1.9-21:     accepted value: 'pull'
 input.y:1.9-21:     accepted value: 'push'
 input.y:1.9-21:     accepted value: 'both'
@@ -1325,65 +1332,37 @@ AT_CLEANUP
 ## %define backward compatibility.  ##
 ## -------------------------------- ##
 
-AT_SETUP([[%define backward compatibility]])
-
-# The error messages tell us whether underscores in these variables are
-# being converted to dashes.
+AT_SETUP([["%define" backward compatibility]])
 
+# The error messages tell us whether the variables are properly updated.
 AT_DATA([[input.y]],
-[[%define api.push_pull "neither"
+[[%define api.push_pull both
+%define lr.keep_unreachable_states maybe
+%define namespace "foo"
+%define api.namespace "foo"
+%define variant
 %%
 start: ;
 ]])
-AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:1.9-21: warning: deprecated directive: '%define api.push_pull 
neither', use '%define api.push-pull neither' [-Wdeprecated]
-input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 
'neither'
-input.y:1.9-21:     accepted value: 'pull'
-input.y:1.9-21:     accepted value: 'push'
-input.y:1.9-21:     accepted value: 'both'
-]])
-
 AT_BISON_CHECK([[-fcaret input.y]], [1], [],
-[[input.y:1.9-21: warning: deprecated directive, use '%define api.push-pull 
neither' [-Wdeprecated]
- %define api.push_pull "neither"
+[[input.y:1.9-21: warning: deprecated directive, use '%define api.push-pull 
both' [-Wdeprecated]
+ %define api.push_pull both
          ^^^^^^^^^^^^^
-input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 
'neither'
- %define api.push_pull "neither"
+input.y:2.9-34: warning: deprecated directive, use '%define 
lr.keep-unreachable-state maybe' [-Wdeprecated]
+ %define lr.keep_unreachable_states maybe
+         ^^^^^^^^^^^^^^^^^^^^^^^^^^
+input.y:3.9-17: warning: deprecated directive, use '%define api.namespace foo' 
[-Wdeprecated]
+ %define namespace "foo"
+         ^^^^^^^^^
+input.y:4.9-21: error: %define variable 'api.namespace' redefined
+ %define api.namespace "foo"
          ^^^^^^^^^^^^^
-input.y:1.9-21:     accepted value: 'pull'
-input.y:1.9-21:     accepted value: 'push'
-input.y:1.9-21:     accepted value: 'both'
-]])
-
-AT_DATA([[input.y]],
-[[%define lr.keep_unreachable_states maybe
-%%
-start: ;
-]])
-AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:1.9-34: warning: deprecated directive: '%define 
lr.keep_unreachable_states maybe', use '%define lr.keep-unreachable-state 
maybe' [-Wdeprecated]
-input.y:1.9-34: error: invalid value for %define Boolean variable 
'lr.keep-unreachable-state'
-]])
-
-AT_DATA([[input.y]],
-[[%define namespace "foo"
-%define api.namespace "foo"
-%%
-start: ;
-]])
-AT_BISON_CHECK([[input.y]], [1], [],
-[[input.y:1.9-17: warning: deprecated directive: '%define namespace foo', use 
'%define api.namespace foo' [-Wdeprecated]
-input.y:2.9-21: error: %define variable 'api.namespace' redefined
-input.y:1.9-17:     previous definition
-]])
-
-AT_DATA([[input.y]],
-[[%define foo_bar "baz"
-%%
-start: ;
-]])
-AT_BISON_CHECK([[input.y]], [[1]], [],
-[[input.y:1.9-15: error: %define variable 'foo_bar' is not used
+input.y:3.9-17:     previous definition
+ %define namespace "foo"
+         ^^^^^^^^^
+input.y:5.9-15: warning: deprecated directive, use '%define api.value.type 
variant' [-Wdeprecated]
+ %define variant
+         ^^^^^^^
 ]])
 
 AT_CLEANUP
@@ -1639,7 +1618,7 @@ AT_CLEANUP
 ## %name-prefix and %define api.prefix are incompatible.  ##
 ## ------------------------------------------------------ ##
 
-AT_SETUP([[%name-prefix and %define api.prefix are incompatible]])
+AT_SETUP([[%name-prefix and api.prefix are incompatible]])
 
 # AT_TEST(DIRECTIVES, OPTIONS, ERROR-LOCATION)
 # --------------------------------------------




reply via email to

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