Le 15 avr. 09 à 22:16, Akim Demaille a écrit :

I have pushed my proposal (which does not include the warning) in candidates/define-error-verbose, whose patch is attached here.

From b4f4b6061a9ea9001e3a01de87f1e97f895e68f5 Mon Sep 17 00:00:00 2001
From: Akim Demaille <[email protected]>
Date: Wed, 15 Apr 2009 21:55:35 +0200
Subject: [PATCH] variables: prefer error-verbose to error_verbose.

        * data/bison.m4 (b4_percent_define_if_define_): Also map dashes to
        underscores.
        (b4_error_verbose_if): Based on error-verbose instead of
        error_verbose.
        * src/scan-gram.l ({id}): Also accept dashes after the initial
        letter.
        ({directive}): Use {id}.
        * doc/bison.texinfo: Promote %define error-verbose instead of
        %error-verbose.
        * tests/actions.at: Prefer %define error-verbose to %error-verbose.
---
 ChangeLog         |   14 ++++++++++++++
 data/bison.m4     |    7 ++++---
 doc/bison.texinfo |   45 ++++++++++++++++++++++++++++++++-------------
 src/scan-gram.l   |    6 +++---
 tests/actions.at  |   16 ++++++++--------
 5 files changed, 61 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f879dbd..fd17a1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-04-15  Akim Demaille  <[email protected]>
+
+       variables: prefer error-verbose to error_verbose.
+       * data/bison.m4 (b4_percent_define_if_define_): Also map dashes to
+       underscores.
+       (b4_error_verbose_if): Based on error-verbose instead of
+       error_verbose.
+       * src/scan-gram.l ({id}): Also accept dashes after the initial
+       letter.
+       ({directive}): Use {id}.
+       * doc/bison.texinfo: Promote %define error-verbose instead of
+       %error-verbose.
+       * tests/actions.at: Prefer %define error-verbose to %error-verbose.
+
 2009-04-14  Akim Demaille  <[email protected]>
 
        variables: use `parse.assert' instead of `assert'.
diff --git a/data/bison.m4 b/data/bison.m4
index 2b4e504..562dea0 100644
--- a/data/bison.m4
+++ b/data/bison.m4
@@ -668,9 +668,10 @@ m4_define([b4_percent_define_default],
 # b4_percent_define_if_define(VARIABLE)
 # -------------------------------------
 # Define b4_VARIABLE_if that executes its $1 or $2 depending whether
-# VARIABLE was %defined.  The character `.' in VARIABLE is mapped to `_'.
+# VARIABLE was %defined.  The character `.' and `-' in VARIABLE are mapped
+# to `_'.
 m4_define([b4_percent_define_if_define_],
-[m4_define(m4_bpatsubst([b4_$1_if], [[.]], [_]),
+[m4_define(m4_bpatsubst([b4_$1_if], [[-.]], [_]),
            [b4_percent_define_flag_if([$1], [$2], [$3])])])
 m4_define([b4_percent_define_if_define],
 [b4_percent_define_default([[$1]], [[false]])
@@ -683,7 +684,7 @@ b4_percent_define_if_define_([$1], $[1], $[2])])
 # b4_lex_symbol_if([IF-YYLEX-RETURNS-A-COMPLETE-SYMBOL], [IF-NOT])
 # b4_variant_if([IF-VARIANT-ARE-USED], [IF-NOT])
 # ----------------------------------------------
-b4_percent_define_if_define([error_verbose])
+b4_percent_define_if_define([error-verbose])
 b4_percent_define_if_define([lex_symbol])
 b4_percent_define_if_define([locations])     # Whether locations are tracked.
 b4_percent_define_if_define([parse.assert])
diff --git a/doc/bison.texinfo b/doc/bison.texinfo
index fbe9ac9..51b1ae2 100644
--- a/doc/bison.texinfo
+++ b/doc/bison.texinfo
@@ -4890,6 +4890,7 @@ Some of the accepted @var{variable}s are:
 
 @item Default Value: @code{"false"}
 @end itemize
+...@c api.pure
 
 @item api.push_pull
 @findex %define api.push_pull
@@ -4906,6 +4907,24 @@ More user feedback will help to stabilize it.)
 
 @item Default Value: @code{"pull"}
 @end itemize
+...@c api.push_pull
+
+...@item error-verbose
+...@findex %define error-verbose
+...@itemize
+...@item Languages(s):
+all.
+...@item Purpose:
+Enable the generation of more verbose error messages than a instead of
+just plain @w...@code{"syntax error"}}.  @xref{Error Reporting, ,The Error
+Reporting Function @code{yyerror}}.
+...@item Accepted Values:
+Boolean
+...@item Default Value:
+...@code{false}
+...@end itemize
+...@c error-verbose
+
 
 @item lr.keep_unreachable_states
 @findex %define lr.keep_unreachable_states
@@ -4949,6 +4968,7 @@ states.
 However, Bison does not compute which goto actions are useless.
 @end itemize
 @end itemize
+...@c lr.keep_unreachable_states
 
 @item namespace
 @findex %define namespace
@@ -5689,8 +5709,8 @@ called by @code{yyparse} whenever a syntax error is 
found, and it
 receives one argument.  For a syntax error, the string is normally
 @w...@code{"syntax error"}}.
 
-...@findex %error-verbose
-If you invoke the directive @code{%error-verbose} in the Bison
+...@findex %define error-verbose
+If you invoke the directive @code{%define error-verbose} in the Bison
 declarations section (@pxref{Bison Declarations, ,The Bison Declarations
 Section}), then Bison provides a more verbose and specific error message
 string instead of just plain @w...@code{"syntax error"}}.
@@ -8580,7 +8600,7 @@ error messages.
 @comment file: calc++-parser.yy
 @example
 %define parse.trace
-%error-verbose
+%define error-verbose
 @end example
 
 @noindent
@@ -9061,7 +9081,7 @@ Run the syntactic analysis, and return @code{true} on 
success,
 @deftypemethod {YYParser} {boolean} getErrorVerbose ()
 @deftypemethodx {YYParser} {void} setErrorVerbose (boolean @var{verbose})
 Get or set the option to produce verbose error messages.  These are only
-available with the @code{%error-verbose} directive, which also turn on
+available with the @code{%define error-verbose} directive, which also turn on
 verbose error messages.
 @end deftypemethod
 
@@ -9990,8 +10010,7 @@ token is reset to the token that originally caused the 
violation.
 @end deffn
 
 @deffn {Directive} %error-verbose
-Bison declaration to request verbose, specific error message strings
-when @code{yyerror} is called.
+An obsolete directive standing for @samp{%define error-verbose}.
 @end deffn
 
 @deffn {Directive} %file-prefix "@var{prefix}"
@@ -10189,16 +10208,16 @@ instead.
 
 @deffn {Function} yyerror
 User-supplied function to be called by @code{yyparse} on error.
-...@xref{error Reporting, ,The Error
-Reporting Function @code{yyerror}}.
+...@xref{error Reporting, ,The Error Reporting Function @code{yyerror}}.
 @end deffn
 
 @deffn {Macro} YYERROR_VERBOSE
-An obsolete macro that you define with @code{#define} in the prologue
-to request verbose, specific error message strings
-when @code{yyerror} is called.  It doesn't matter what definition you
-use for @code{YYERROR_VERBOSE}, just whether you define it.  Using
-...@code{%error-verbose} is preferred.
+An obsolete macro used in the @file{yacc.c} skeleton, that you define
+with @code{#define} in the prologue to request verbose, specific error
+message strings when @code{yyerror} is called.  It doesn't matter what
+definition you use for @code{YYERROR_VERBOSE}, just whether you define
+it.  Using @code{%define error-verbose} is preferred (@pxref{Error
+Reporting, ,The Error Reporting Function @code{yyerror}}).
 @end deffn
 
 @deffn {Macro} YYINITDEPTH
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 478d096..b1daac5 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -99,8 +99,8 @@ static void unexpected_newline (boundary, char const *);
 %x SC_STRING SC_CHARACTER
 
 letter   [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
-id       {letter}({letter}|[0-9])*
-directive %{letter}({letter}|[0-9]|-)*
+id       {letter}({letter}|[0-9]|-)*
+directive %{id}
 int      [0-9]+
 
 /* POSIX says that a tag must be both an id and a C union member, but
@@ -181,7 +181,7 @@ splice       (\\[ \f\t\v]*\n)*
   "%defines"                        return PERCENT_DEFINES;
   "%destructor"                     return PERCENT_DESTRUCTOR;
   "%dprec"                          return PERCENT_DPREC;
-  "%error"[-_]"verbose"             RETURN_PERCENT_FLAG("error_verbose");
+  "%error"[-_]"verbose"             RETURN_PERCENT_FLAG("error-verbose");
   "%expect"                         return PERCENT_EXPECT;
   "%expect"[-_]"rr"                 return PERCENT_EXPECT_RR;
   "%file-prefix"                    return PERCENT_FILE_PREFIX;
diff --git a/tests/actions.at b/tests/actions.at
index 841ae39..371cf84 100644
--- a/tests/actions.at
+++ b/tests/actions.at
@@ -1,6 +1,6 @@
 # Executing Actions.                               -*- Autotest -*-
-# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
-# Foundation, Inc.
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@ AT_SETUP([Mid-rule actions])
 # action.
 
 AT_DATA_GRAMMAR([[input.y]],
-[[%error-verbose
+[[%define error-verbose
 %debug
 %{
 # include <stdio.h>
@@ -93,7 +93,7 @@ AT_CLEANUP
 AT_SETUP([Exotic Dollars])
 
 AT_DATA_GRAMMAR([[input.y]],
-[[%error-verbose
+[[%define error-verbose
 %debug
 %{
 # include <stdio.h>
@@ -557,7 +557,7 @@ m4_define([AT_CHECK_PRINTER_AND_DESTRUCTOR],
 
 $3
 _AT_CHECK_PRINTER_AND_DESTRUCTOR($[1], $[2], $[3], $[4],
-[%error-verbose
+[%define error-verbose
 %debug
 %verbose
 %locations
@@ -588,7 +588,7 @@ AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser], [with union])
 AT_SETUP([Default tagless %printer and %destructor])
 
 AT_DATA_GRAMMAR([[input.y]],
-[[%error-verbose
+[[%define error-verbose
 %debug
 %locations
 %initial-action {
@@ -706,7 +706,7 @@ AT_CLEANUP
 AT_SETUP([Default tagged and per-type %printer and %destructor])
 
 AT_DATA_GRAMMAR([[input.y]],
-[[%error-verbose
+[[%define error-verbose
 %debug
 
 %{
@@ -850,7 +850,7 @@ 
m4_define([_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN],
   [m4_pushdef([kind], [*]) m4_pushdef([not_kind], [])])
 
 AT_DATA_GRAMMAR([[input]]$1[[.y]],
-[[%error-verbose
+[[%define error-verbose
 %debug
 %locations
 %initial-action {
-- 
1.6.2.2


Reply via email to