Improve error messages.

This commit is contained in:
Anthony J. Bentley
2013-05-19 17:07:34 -06:00
parent 51c01e3aad
commit c21c0f458f
7 changed files with 62 additions and 79 deletions

View File

@@ -7,6 +7,7 @@
#include <math.h>
#include <getopt.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -205,18 +206,26 @@ opt_Pop(void)
*/
void
yyerror(char *s)
yyerror(const char *fmt, ...)
{
printf("*ERROR*\t");
fprintf(stderr, "ERROR:\t");
fstk_Dump();
printf(" :\n\t%s\n", s);
fprintf(stderr, " :\n\t");
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
nErrors += 1;
}
void
fatalerror(char *s)
fatalerror(const char *fmt, ...)
{
yyerror(s);
va_list args;
va_start(args, fmt);
yyerror(fmt, args);
va_end(args);
exit(5);
}
/*