[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/6] regen
From: |
Akim Demaille |
Subject: |
[PATCH 6/6] regen |
Date: |
Thu, 23 Jan 2020 08:51:01 +0100 |
---
src/parse-gram.c | 53 ++++++------------------------------------------
1 file changed, 6 insertions(+), 47 deletions(-)
diff --git a/src/parse-gram.c b/src/parse-gram.c
index c36be42f..1c988c38 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -2709,58 +2709,17 @@ yyreturn:
int
yyreport_syntax_error (const yyparse_context_t *ctx)
{
- if (complaint_status < status_complaint)
- complaint_status = status_complaint;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- /* Internationalized format string. */
- const char *format = YY_NULLPTR;
/* Arguments of format: reported tokens (one for the "unexpected",
one per "expected"). */
int arg[YYERROR_VERBOSE_ARGS_MAXIMUM];
int n = yysyntax_error_arguments (ctx, arg, YYERROR_VERBOSE_ARGS_MAXIMUM);
- switch (n)
- {
- case -2:
- return 2;
-# define YYCASE_(N, S) \
- case N: \
- format = S; \
- break
- default: /* Avoid compiler warnings. */
- YYCASE_(0, YY_("syntax error"));
- YYCASE_(1, YY_("syntax error, unexpected %s"));
- YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
- YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
- YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
- YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or
%s"));
-# undef YYCASE_
- }
- location_print (*yyparse_context_location (ctx), stderr);
- fputs (": ", stderr);
- begin_use_class ("error", stderr);
- fputs ("error:", stderr);
- end_use_class ("error", stderr);
- fputc (' ', stderr);
- {
- int i = 0;
- while (*format)
- if (format[0] == '%' && format[1] == 's' && i < n)
- {
- const char *style = i == 0 ? "unexpected" : "expected";
- begin_use_class (style, stderr);
- fputs (yysymbol_name (arg[i]), stderr);
- end_use_class (style, stderr);
- format += 2;
- ++i;
- }
- else
- {
- fputc (*format, stderr);
- ++format;
- }
- }
- fputc ('\n', stderr);
- location_caret (*yyparse_context_location (ctx), "error", stderr);
+ if (n == -2)
+ return 2;
+ const char *argv[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ for (int i = 0; i < n; ++i)
+ argv[i] = yysymbol_name (arg[i]);
+ syntax_error (*yyparse_context_location (ctx), n, argv);
return 0;
}
--
2.25.0
- [PATCH 0/6] diagnostics: improve bison's syntax error messages, Akim Demaille, 2020/01/23
- [PATCH 1/6] diagnostics: translate bison's own tokens, Akim Demaille, 2020/01/23
- [PATCH 2/6] regen, Akim Demaille, 2020/01/23
- [PATCH 3/6] diagnostics: report syntax errors in color, Akim Demaille, 2020/01/23
- [PATCH 4/6] regen, Akim Demaille, 2020/01/23
- [PATCH 6/6] regen,
Akim Demaille <=
- [PATCH 5/6] diagnostics: modernize bison's syntax errors, Akim Demaille, 2020/01/23
- Re: [PATCH 0/6] diagnostics: improve bison's syntax error messages, Akim Demaille, 2020/01/25