+2009-06-29 Akim Demaille <demaille@gostai.com>
+
+ variables: parse.error
+
+ Implement, document, and test the replacement of %error-verbose
+ by %define parse.error "verbose".
+ * data/bison.m4 (b4_error_verbose_if): Reimplement to track the
+ values of the parse.error variable.
+ Make "simple" its default value.
+ Check the valid values.
+ * src/parse-gram.y: Use %define parse.error.
+ (PERCENT_ERROR_VERBOSE): New token.
+ Support it.
+ * src/scan-gram.l: Support %error-verbose.
+
+ * doc/bison.texinfo (Decl Summary): Replace the documentation of
+ %define error-verbose by that of %define parse.error.
+ * NEWS: Document it.
+
+ * tests/actions.at, tests/calc.at: Use parse.error instead of
+ %error-verbose.
+
2009-06-27 Alex Rozenman <rozenman@gmail.com>
Implement support for named symbol references.
The "namespace" variable is renamed "api.namespace". Backward
compatibility is ensured, but upgrading is recommended.
+** Variable parse.error
+
+ The variable error controls the verbosity of error messages. The
+ use of the %error-verbose directive is deprecated in favor of
+ %define parse.error "verbose".
+
* Changes in version 2.5 (????-??-??):
** IELR(1) and Canonical LR(1) Support
# b4_parse_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
# b4_parse_trace_if([IF-DEBUG-TRACES-ARE-ENABLED], [IF-NOT])
-# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
# 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([lex_symbol])
b4_percent_define_if_define([locations]) # Whether locations are tracked.
b4_percent_define_if_define([parse.assert])
b4_percent_define_if_define([variant])
+# b4_error_verbose_if([IF-ERRORS-ARE-VERBOSE], [IF-NOT])
+# ------------------------------------------------------
+# Map %define parse.error "(simple|verbose)" to b4_error_verbose_if and
+# b4_error_verbose_flag.
+b4_percent_define_default([[parse.error]], [[simple]])
+b4_percent_define_check_values([[[[parse.error]],
+ [[simple]], [[verbose]]]])
+m4_case(b4_percent_define_get([[parse.error]]),
+ [simple], [m4_define([b4_error_verbose_flag], [[0]])],
+ [verbose], [m4_define([b4_error_verbose_flag], [[1]])])
+b4_define_flag_if([error_verbose])
+
# b4_percent_define_check_values(VALUES)
# --------------------------------------
@c api.tokens.prefix
-@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.default-reductions
@cindex default reductions
@findex %define lr.default-reductions
Obsoleted by @code{api.namespace}
@c namespace
+
+@c ================================================== parse.assert
@item parse.assert
@findex %define parse.assert
@end itemize
@c parse.assert
+
+@c ================================================== parse.error
+@item parse.error
+@findex %define parse.error
+@itemize
+@item Languages(s):
+all.
+@item Purpose:
+Control the kind of error messages passed to the error reporting
+function. @xref{Error Reporting, ,The Error Reporting Function
+@code{yyerror}}.
+@item Accepted Values:
+@itemize
+@item @code{"simple"}
+Error messages passed to @code{yyerror} are simply @w{@code{"syntax
+error"}}.
+@item @code{"verbose"}
+Error messages report the unexpected token, and possibly the expected
+ones.
+@end itemize
+
+@item Default Value:
+@code{simple}
+@end itemize
+@c parse.error
+
+
+@c ================================================== parse.trace
@item parse.trace
@findex %define parse.trace
@cindex parse error
@cindex syntax error
-The Bison parser detects a @dfn{syntax error} or @dfn{parse error}
+The Bison parser detects a @dfn{syntax error} (or @dfn{parse error})
whenever it reads a token which cannot satisfy any syntax rule. An
action in the grammar can also explicitly proclaim an error, using the
macro @code{YYERROR} (@pxref{Action Features, ,Special Features for Use
receives one argument. For a syntax error, the string is normally
@w{@code{"syntax error"}}.
-@findex %define error-verbose
-If you invoke the directive @samp{%define error-verbose} in the Bison
+@findex %define parse.error
+If you invoke @samp{%define parse.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"}}.
@comment file: calc++-parser.yy
@example
%define parse.trace
-%define error-verbose
+%define parse.error "verbose"
@end example
@noindent
@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 @samp{%define error-verbose} directive, which also turn on
+available with @samp{%define parse.error "verbose"}, which also turns on
verbose error messages.
@end deftypemethod
@end deffn
@deffn {Directive} %error-verbose
-An obsolete directive standing for @samp{%define error-verbose}.
+An obsolete directive standing for @samp{%define parse.error "verbose"}.
@end deffn
@deffn {Directive} %file-prefix "@var{prefix}"
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 @samp{%define error-verbose} is preferred (@pxref{Error
-Reporting, ,The Error Reporting Function @code{yyerror}}).
+it. Using @samp{%define parse.error "verbose"} is preferred
+(@pxref{Error Reporting, ,The Error Reporting Function @code{yyerror}}).
@end deffn
@deffn {Macro} YYINITDEPTH
%defines
%locations
%pure-parser
-%error-verbose
+%define parse.error "verbose"
%name-prefix="gram_"
%expect 0
PERCENT_DEFAULT_PREC "%default-prec"
PERCENT_DEFINE "%define"
PERCENT_DEFINES "%defines"
+ PERCENT_ERROR_VERBOSE "%error-verbose"
PERCENT_EXPECT "%expect"
PERCENT_EXPECT_RR "%expect-rr"
PERCENT_FLAG "%<flag>"
defines_flag = true;
spec_defines_file = xstrdup ($2);
}
+| "%error-verbose"
+ {
+ muscle_percent_define_insert ("parse.error", @1, "verbose",
+ MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
+ }
| "%expect" INT { expected_sr_conflicts = $2; }
| "%expect-rr" INT { expected_rr_conflicts = $2; }
| "%file-prefix" STRING { spec_file_prefix = $2; }
"%defines" return PERCENT_DEFINES;
"%destructor" return PERCENT_DESTRUCTOR;
"%dprec" return PERCENT_DPREC;
- "%error"[-_]"verbose" RETURN_PERCENT_FLAG("error-verbose");
+ "%error"[-_]"verbose" return PERCENT_ERROR_VERBOSE;
"%expect" return PERCENT_EXPECT;
"%expect"[-_]"rr" return PERCENT_EXPECT_RR;
"%file-prefix" return PERCENT_FILE_PREFIX;
# action.
AT_DATA_GRAMMAR([[input.y]],
-[[%define error-verbose
+[[%define parse.error "verbose"
%debug
%{
# include <stdio.h>
AT_SETUP([Exotic Dollars])
AT_DATA_GRAMMAR([[input.y]],
-[[%define error-verbose
+[[%define parse.error "verbose"
%debug
%{
# include <stdio.h>
$3
_AT_CHECK_PRINTER_AND_DESTRUCTOR($[1], $[2], $[3], $[4],
-[%define error-verbose
+[%define parse.error "verbose"
%debug
%verbose
%locations
AT_SETUP([Default tagless %printer and %destructor])
AT_DATA_GRAMMAR([[input.y]],
-[[%define error-verbose
+[[%define parse.error "verbose"
%debug
%locations
%initial-action {
AT_SETUP([Default tagged and per-type %printer and %destructor])
AT_DATA_GRAMMAR([[input.y]],
-[[%define error-verbose
+[[%define parse.error "verbose"
%debug
%{
[m4_pushdef([kind], [*]) m4_pushdef([not_kind], [])])
AT_DATA_GRAMMAR([[input]]$1[[.y]],
-[[%define error-verbose
+[[%define parse.error "verbose"
%debug
%locations
%initial-action {
# If BISON-OPTIONS contains `%location', then make sure the ERROR-LOCATION
# is correctly output on stderr.
#
-# If BISON-OPTIONS contains `%error-verbose', then make sure the
+# If BISON-OPTIONS contains `%define parse.error "verbose"', then make sure the
# IF-YYERROR-VERBOSE message is properly output after `syntax error, '
# on STDERR.
#
[[sed 's/^[-0-9.]*: //' expout >at-expout
mv at-expout expout]])
# 4. If error-verbose is not used, strip the`, unexpected....' part.
-m4_bmatch([$1], [%error-verbose], [],
+m4_bmatch([$1], [%define parse.error "verbose"], [],
[[sed 's/syntax error, .*$/syntax error/' expout >at-expout
mv at-expout expout]])
# 5. Check
AT_CHECK_CALC_LALR([%name-prefix="calc"]) dnl test deprecated `='
AT_CHECK_CALC_LALR([%verbose])
AT_CHECK_CALC_LALR([%yacc])
-AT_CHECK_CALC_LALR([%error-verbose])
+AT_CHECK_CALC_LALR([%define parse.error "verbose"])
AT_CHECK_CALC_LALR([%define api.pure %locations])
AT_CHECK_CALC_LALR([%define api.push-pull "both" %define api.pure %locations])
-AT_CHECK_CALC_LALR([%error-verbose %locations])
+AT_CHECK_CALC_LALR([%define parse.error "verbose" %locations])
-AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define parse.error "verbose" %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define parse.error "verbose" %locations %defines %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
AT_CHECK_CALC_LALR([%debug])
-AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define parse.error "verbose" %debug %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%define api.push-pull "both" %define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define api.pure %define parse.error "verbose" %debug %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR([%define api.push-pull "both" %define api.pure %define parse.error "verbose" %debug %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_LALR([%define api.pure %define parse.error "verbose" %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
# ----------------------- #
AT_CHECK_CALC_GLR([%name-prefix "calc"])
AT_CHECK_CALC_GLR([%verbose])
AT_CHECK_CALC_GLR([%yacc])
-AT_CHECK_CALC_GLR([%error-verbose])
+AT_CHECK_CALC_GLR([%define parse.error "verbose"])
AT_CHECK_CALC_GLR([%define api.pure %locations])
-AT_CHECK_CALC_GLR([%error-verbose %locations])
+AT_CHECK_CALC_GLR([%define parse.error "verbose" %locations])
-AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define parse.error "verbose" %locations %defines %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR([%debug])
-AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define parse.error "verbose" %debug %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define parse.error "verbose" %debug %locations %defines %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
-AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR([%define api.pure %define parse.error "verbose" %debug %locations %defines %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_GLR([%define api.pure %define parse.error "verbose" %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
# ----------------------------- #
AT_CHECK_CALC_LALR1_CC([])
AT_CHECK_CALC_LALR1_CC([%locations])
-AT_CHECK_CALC_LALR1_CC([%locations %error-verbose %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %define parse.error "verbose" %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR1_CC([%locations %error-verbose %debug %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %define parse.error "verbose" %debug %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error "verbose" %debug %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error "verbose" %debug %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
-AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error "verbose" %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
[AT_CHECK_CALC([%language "C++" %glr-parser %defines %locations] $@)])
AT_CHECK_CALC_GLR_CC([])
-AT_CHECK_CALC_GLR_CC([%error-verbose %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%define parse.error "verbose" %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_GLR_CC([%debug])
-AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%define parse.error "verbose" %debug %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
-AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error "verbose" %debug %name-prefix "calc" %verbose %yacc])
+AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error "verbose" %debug %name-prefix "calc" %define api.tokens.prefix "TOK_" %verbose %yacc])
-AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])
+AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error "verbose" %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])