2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 * Author: Ceriel J.H. Jacobs
8 /* E R R O R A N D D I A G N O S T I C R O U T I N E S */
10 /* stripped down version from the one in the Modula-2 compiler */
11 /* $Id: error.c,v 1.4 1995/08/17 15:20:35 ceriel Exp $ */
13 /* This file contains the error-message and diagnostic
14 giving functions. Be aware that they are called with a variable
36 extern char *symbol2str();
38 /* There are three general error-message functions:
39 lexerror() lexical and pre-processor error messages
40 error() syntactic and semantic error messages
41 node_error() errors in nodes
42 The difference lies in the place where the file name and line
44 Lexical errors report from the global variables LineNumber and
45 FileName, node errors get their information from the
46 node, whereas other errors use the information in the token.
56 _error(ERROR, fmt, ap);
61 Gerror(char *fmt, ...)
68 _error(ERROR, fmt, ap);
74 lexerror(char *fmt, ...)
79 _error(LEXERROR, fmt, ap);
89 _error(FATAL, fmt, ap);
100 _error(CRASH, fmt, ap);
117 fmt = va_arg(ap, char *);
118 _error(ERROR, fmt, ap);
132 fmt = va_arg(ap, char *);
133 _error(ERROR, fmt, ap);
146 fmt = va_arg(ap, char *);
147 _error(LEXERROR, fmt, ap);
159 fmt = va_arg(ap, char *);
160 _error(FATAL, fmt, ap);
173 fmt = va_arg(ap, char *);
174 _error(CRASH, fmt, ap);
184 _error(class, fmt, argv)
189 /* _error attempts to limit the number of error messages
190 for a given line to MAXERR_LINE.
193 register char *remark = 0;
195 /* Since name and number are gathered from different places
196 depending on the class, we first collect the relevant
197 values and then decide what to print.
212 remark = "CRASH\007";
215 remark = "fatal error --";
231 if (FileName) fprint(STDERR, "\"%s\", line %u: ", FileName, ln);
233 if (remark) fprint(STDERR, "%s ", remark);
235 doprnt(STDERR, fmt, argv); /* contents of error */
236 fprint(STDERR, "\n");