Fix some error-reporting macro bugs.

* data/bison.m4 (b4_cat): New.
(b4_error, b4_error_at): Use b4_cat to send error directives directly
to stdout so they don't become arguments to other macros.  Update
comments and add examples.
(b4_warn, b4_warn_at, b4_complain, b4_complain_at): Update comments and
add examples.
(b4_fatal, b4_fatal_at): Likewise, and invoke m4_exit(1) immediately
after printing the error directive so that M4 doesn't report subsequent
problems that are induced by this problem.
* src/scan-skel.l: Recognize @` digraph outside of directive arguments
instead of just in them.  Recognize @\n in both places.  Both expand to
the empty string.  Needed by b4_cat.
* tests/skeletons.at (Complaining during macro argument expansion):
New test case.
(Fatal errors make M4 exit immediately): New test case.
This commit is contained in:
Joel E. Denny
2007-10-08 01:53:08 +00:00
parent d4bd229569
commit 7dc4a6940c
4 changed files with 184 additions and 34 deletions

View File

@@ -70,9 +70,11 @@ static void fail_for_invalid_at (char const *at);
char *at_directive_argv[AT_DIRECTIVE_ARGC_MAX];
%}
"@@" fputc ('@', yyout);
"@{" fputc ('[', yyout);
"@}" fputc (']', yyout);
"@@" fputc ('@', yyout);
"@{" fputc ('[', yyout);
"@}" fputc (']', yyout);
"@`" /* Emtpy. Used by b4_cat in ../data/bison.m4. */
@\n /* Likewise. */
"@oline@" fprintf (yyout, "%d", out_lineno + 1);
"@ofile@" QPUTS (outname);
@@ -87,7 +89,7 @@ static void fail_for_invalid_at (char const *at);
}
/* This pattern must not match more than the previous @ patterns. */
@[^@{}(\n]* fail_for_invalid_at (yytext);
@[^@{}`(\n]* fail_for_invalid_at (yytext);
\n out_lineno++; ECHO;
[^@\n]+ ECHO;
@@ -108,6 +110,7 @@ static void fail_for_invalid_at (char const *at);
"@}" { obstack_1grow (&obstack_for_string, ']'); }
"@`" /* Emtpy. Useful for starting an argument
that begins with whitespace. */
@\n /* Empty. */
@[,)] {
if (at_directive_argc >= AT_DIRECTIVE_ARGC_MAX)