mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 17:23:02 +00:00
errors: factor b4_error @directives
Instead of @complain, @warn, and @fatal, use a unique @complain directive. This directive's first argument is "complain", "warn", etc. * data/bison.m4 (m4_error): Here. * src/scan-skel.l (at_directive_perform): Adjust. (flag): Replace the switch by safer and more explicit if branches. Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
This commit is contained in:
committed by
Akim Demaille
parent
b999409e09
commit
0505df0cba
@@ -91,7 +91,7 @@ m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write to stdout])])])
|
|||||||
# b4_error([[complain]], [[input.y:2.3]], [[input.y:5.4]],
|
# b4_error([[complain]], [[input.y:2.3]], [[input.y:5.4]],
|
||||||
# [[invalid %s]], [[foo]])
|
# [[invalid %s]], [[foo]])
|
||||||
m4_define([b4_error],
|
m4_define([b4_error],
|
||||||
[b4_cat([[@]$1[(]$2[@,]$3[@,]$4[]]dnl
|
[b4_cat([[@complain][(]$1[@,]$2[@,]$3[@,]$4[]]dnl
|
||||||
[m4_if([$#], [4], [],
|
[m4_if([$#], [4], [],
|
||||||
[m4_foreach([b4_arg],
|
[m4_foreach([b4_arg],
|
||||||
m4_dquote(m4_shift(m4_shift(m4_shift(m4_shift($@))))),
|
m4_dquote(m4_shift(m4_shift(m4_shift(m4_shift($@))))),
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ static void fail_for_invalid_at (char const *at);
|
|||||||
int out_lineno PACIFY_CC (= 0);
|
int out_lineno PACIFY_CC (= 0);
|
||||||
char *outname = NULL;
|
char *outname = NULL;
|
||||||
|
|
||||||
/* Currently, only the @warn, @complain, @fatal, @warn_at, @complain_at, and
|
/* Currently, only the @complain directive takes multiple arguments, and
|
||||||
@fatal_at directives take multiple arguments, and the last three already
|
never more than 7, with argv[0] being the directive name and argv[1]
|
||||||
can't take more than 7. argv[0] is the directive name. */
|
being the type of complaint to dispatch. */
|
||||||
#define ARGC_MAX 8
|
#define ARGC_MAX 9
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
char *argv[ARGC_MAX];
|
char *argv[ARGC_MAX];
|
||||||
%}
|
%}
|
||||||
@@ -168,13 +168,15 @@ skel_scanner_free (void)
|
|||||||
static inline warnings
|
static inline warnings
|
||||||
flag (const char *arg)
|
flag (const char *arg)
|
||||||
{
|
{
|
||||||
switch (arg[1])
|
/* compare with values issued from b4_error */
|
||||||
{
|
if (STREQ (arg, "warn"))
|
||||||
case 'w': return Wother;
|
return Wother;
|
||||||
case 'c': return complaint;
|
else if (STREQ (arg, "complain"))
|
||||||
case 'f': return fatal;
|
return complaint;
|
||||||
default: aver (false); break;
|
else if (STREQ (arg, "fatal"))
|
||||||
}
|
return fatal;
|
||||||
|
else
|
||||||
|
aver (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -186,24 +188,20 @@ at_directive_perform (int argc, char *argv[], char **outnamep, int *out_linenop)
|
|||||||
fail_for_at_directive_too_many_args (argv[0]);
|
fail_for_at_directive_too_many_args (argv[0]);
|
||||||
fputs (last_component (argv[1]), yyout);
|
fputs (last_component (argv[1]), yyout);
|
||||||
}
|
}
|
||||||
else if (STREQ (argv[0], "@warn")
|
else if (STREQ (argv[0], "@complain"))
|
||||||
|| STREQ (argv[0], "@complain")
|
|
||||||
|| STREQ (argv[0], "@fatal"))
|
|
||||||
{
|
{
|
||||||
warnings w = flag (*argv);
|
|
||||||
location loc;
|
|
||||||
location *locp = NULL;
|
|
||||||
if (argc < 4)
|
if (argc < 4)
|
||||||
fail_for_at_directive_too_few_args (argv[0]);
|
fail_for_at_directive_too_few_args (argv[0]);
|
||||||
if (argv[1] && argv[1][0])
|
warnings w = flag (argv[1]);
|
||||||
|
location loc;
|
||||||
|
location *locp = NULL;
|
||||||
|
if (argv[2] && argv[2][0])
|
||||||
{
|
{
|
||||||
boundary_set_from_string (&loc.start, argv[1]);
|
boundary_set_from_string (&loc.start, argv[2]);
|
||||||
boundary_set_from_string (&loc.end, argv[2]);
|
boundary_set_from_string (&loc.end, argv[3]);
|
||||||
locp = &loc;
|
locp = &loc;
|
||||||
}
|
}
|
||||||
argc -= 2;
|
complain_args (locp, w, argc - 3, argv + 3);
|
||||||
argv += 2;
|
|
||||||
complain_args (locp, w, argc, argv);
|
|
||||||
}
|
}
|
||||||
else if (STREQ (argv[0], "@output"))
|
else if (STREQ (argv[0], "@output"))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user