mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 09:13:04 +00:00
warnings: simplify the m4 interface
* data/bison.m4 (error_at): Replace... (error): this. (b4_warn, b4_complain, b4_fatal): Bounce to their _at equivalent, with empty location. * src/scan-skel.l (at_directive_perform): Simplify accordingly.
This commit is contained in:
@@ -82,30 +82,16 @@ _m4eof
|
|||||||
])dnl
|
])dnl
|
||||||
m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write to stdout])])])
|
m4_if(m4_sysval, [0], [], [m4_fatal([$0: cannot write to stdout])])])
|
||||||
|
|
||||||
# b4_error(KIND, FORMAT, [ARG1], [ARG2], ...)
|
# b4_error(KIND, START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -------------------------------------------
|
# -------------------------------------------------------
|
||||||
# Write @KIND(FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
# Write @KIND(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
||||||
#
|
#
|
||||||
# For example:
|
# For example:
|
||||||
#
|
#
|
||||||
# b4_error([[warn]], [[invalid value for '%s': %s]], [[foo]], [[3]])
|
# b4_error([[complain]], [[input.y:2.3]], [[input.y:5.4]],
|
||||||
|
# [[invalid %s]], [[foo]])
|
||||||
m4_define([b4_error],
|
m4_define([b4_error],
|
||||||
[b4_cat([[@]$1[(]$2[]]dnl
|
[b4_cat([[@]$1[(]$2[@,]$3[@,]$4[]]dnl
|
||||||
[m4_if([$#], [2], [],
|
|
||||||
[m4_foreach([b4_arg],
|
|
||||||
m4_dquote(m4_shift(m4_shift($@))),
|
|
||||||
[[@,]b4_arg])])[@)]])])
|
|
||||||
|
|
||||||
# b4_error_at(KIND, START, END, FORMAT, [ARG1], [ARG2], ...)
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
# Write @KIND_at(START@,END@,FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
|
||||||
#
|
|
||||||
# For example:
|
|
||||||
#
|
|
||||||
# b4_error_at([[complain]], [[input.y:2.3]], [[input.y:5.4]],
|
|
||||||
# [[invalid %s]], [[foo]])
|
|
||||||
m4_define([b4_error_at],
|
|
||||||
[b4_cat([[@]$1[_at(]$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($@))))),
|
||||||
@@ -125,21 +111,21 @@ m4_define([b4_error_at],
|
|||||||
# m4_define([asdf], [ASDF])
|
# m4_define([asdf], [ASDF])
|
||||||
# m4_define([fsa], [FSA])
|
# m4_define([fsa], [FSA])
|
||||||
# m4_define([fdsa], [FDSA])
|
# m4_define([fdsa], [FDSA])
|
||||||
# b4_warn([[[asdf), asdf]]], [[[fsa), fsa]]], [[[fdsa), fdsa]]])
|
# b4_warn_at([[[asdf), asdf]]], [[[fsa), fsa]]], [[[fdsa), fdsa]]])
|
||||||
# b4_warn([[asdf), asdf]], [[fsa), fsa]], [[fdsa), fdsa]])
|
# b4_warn_at([[asdf), asdf]], [[fsa), fsa]], [[fdsa), fdsa]])
|
||||||
# b4_warn()
|
# b4_warn_at()
|
||||||
# b4_warn(1)
|
# b4_warn_at(1)
|
||||||
# b4_warn(1, 2)
|
# b4_warn_at(1, 2)
|
||||||
#
|
#
|
||||||
# Should produce this without newlines:
|
# Should produce this without newlines:
|
||||||
#
|
#
|
||||||
# @warn([asdf), asdf]@,[fsa), fsa]@,[fdsa), fdsa]@)
|
# @warn_at([asdf), asdf]@,@,@,[fsa), fsa]@,[fdsa), fdsa]@)
|
||||||
# @warn(asdf), asdf@,fsa), fsa@,fdsa), fdsa@)
|
# @warn(asdf), asdf@,@,@,fsa), fsa@,fdsa), fdsa@)
|
||||||
# @warn(@)
|
# @warn(@)
|
||||||
# @warn(1@)
|
# @warn(1@)
|
||||||
# @warn(1@,2@)
|
# @warn(1@,2@)
|
||||||
m4_define([b4_warn],
|
m4_define([b4_warn],
|
||||||
[b4_error([[warn]], $@)])
|
[b4_error([[warn]], [], [], $@)])
|
||||||
|
|
||||||
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ---------------------------------------------------
|
# ---------------------------------------------------
|
||||||
@@ -149,15 +135,15 @@ m4_define([b4_warn],
|
|||||||
#
|
#
|
||||||
# b4_warn_at([[input.y:2.3]], [[input.y:5.4]], [[invalid %s]], [[foo]])
|
# b4_warn_at([[input.y:2.3]], [[input.y:5.4]], [[invalid %s]], [[foo]])
|
||||||
m4_define([b4_warn_at],
|
m4_define([b4_warn_at],
|
||||||
[b4_error_at([[warn]], $@)])
|
[b4_error([[warn]], $@)])
|
||||||
|
|
||||||
# b4_complain(FORMAT, [ARG1], [ARG2], ...)
|
# b4_complain(FORMAT, [ARG1], [ARG2], ...)
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
# Write @complain(FORMAT@,ARG1@,ARG2@,...@) to stdout.
|
# Bounce to b4_complain_at.
|
||||||
#
|
#
|
||||||
# See b4_warn example.
|
# See b4_warn example.
|
||||||
m4_define([b4_complain],
|
m4_define([b4_complain],
|
||||||
[b4_error([[complain]], $@)])
|
[b4_error([[complain]], [], [], $@)])
|
||||||
|
|
||||||
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -------------------------------------------------------
|
# -------------------------------------------------------
|
||||||
@@ -165,15 +151,15 @@ m4_define([b4_complain],
|
|||||||
#
|
#
|
||||||
# See b4_warn_at example.
|
# See b4_warn_at example.
|
||||||
m4_define([b4_complain_at],
|
m4_define([b4_complain_at],
|
||||||
[b4_error_at([[complain]], $@)])
|
[b4_error([[complain]], $@)])
|
||||||
|
|
||||||
# b4_fatal(FORMAT, [ARG1], [ARG2], ...)
|
# b4_fatal(FORMAT, [ARG1], [ARG2], ...)
|
||||||
# -------------------------------------
|
# -------------------------------------
|
||||||
# Write @fatal(FORMAT@,ARG1@,ARG2@,...@) to stdout and exit.
|
# Bounce to b4_fatal_at.
|
||||||
#
|
#
|
||||||
# See b4_warn example.
|
# See b4_warn example.
|
||||||
m4_define([b4_fatal],
|
m4_define([b4_fatal],
|
||||||
[b4_error([[fatal]], $@)dnl
|
[b4_error([[fatal]], [], [], $@)dnl
|
||||||
m4_exit(1)])
|
m4_exit(1)])
|
||||||
|
|
||||||
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
|
||||||
@@ -182,7 +168,7 @@ m4_exit(1)])
|
|||||||
#
|
#
|
||||||
# See b4_warn_at example.
|
# See b4_warn_at example.
|
||||||
m4_define([b4_fatal_at],
|
m4_define([b4_fatal_at],
|
||||||
[b4_error_at([[fatal]], $@)dnl
|
[b4_error([[fatal]], $@)dnl
|
||||||
m4_exit(1)])
|
m4_exit(1)])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -186,25 +186,23 @@ 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") || STREQ (argv[0], "@warn_at")
|
else if (STREQ (argv[0], "@warn")
|
||||||
|| STREQ (argv[0], "@complain") || STREQ (argv[0], "@complain_at")
|
|| STREQ (argv[0], "@complain")
|
||||||
|| STREQ (argv[0], "@fatal") || STREQ (argv[0], "@fatal_at"))
|
|| STREQ (argv[0], "@fatal"))
|
||||||
{
|
{
|
||||||
warnings w = flag (*argv);
|
warnings w = flag (*argv);
|
||||||
location loc;
|
location loc;
|
||||||
location *locp = NULL;
|
location *locp = NULL;
|
||||||
if (STREQ (*argv + strlen (*argv) - 3, "_at"))
|
if (argc < 4)
|
||||||
|
fail_for_at_directive_too_few_args (argv[0]);
|
||||||
|
if (argv[1] && argv[1][0])
|
||||||
{
|
{
|
||||||
if (argc < 4)
|
|
||||||
fail_for_at_directive_too_few_args (argv[0]);
|
|
||||||
boundary_set_from_string (&loc.start, argv[1]);
|
boundary_set_from_string (&loc.start, argv[1]);
|
||||||
boundary_set_from_string (&loc.end, argv[2]);
|
boundary_set_from_string (&loc.end, argv[2]);
|
||||||
argc -= 2;
|
|
||||||
argv += 2;
|
|
||||||
locp = &loc;
|
locp = &loc;
|
||||||
}
|
}
|
||||||
else if (argc < 2)
|
argc -= 2;
|
||||||
fail_for_at_directive_too_few_args (argv[0]);
|
argv += 2;
|
||||||
complain_args (locp, w, argc, argv);
|
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