summaryrefslogtreecommitdiff
path: root/parse/err.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-02-22 21:16:03 -0800
committerOri Bernstein <ori@eigenstate.org>2016-02-22 21:16:03 -0800
commit2e1ba4c068a5a5a19fd138d6de8c34561b02d5c9 (patch)
tree6e67712593a057b6fc6ff7bdc16ee807dc09fb21 /parse/err.c
parent8583926c2ca8407a025991f65287bd693dce9060 (diff)
downloadmc-2e1ba4c068a5a5a19fd138d6de8c34561b02d5c9.tar.gz
Add missing file.
Diffstat (limited to 'parse/err.c')
-rw-r--r--parse/err.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/parse/err.c b/parse/err.c
new file mode 100644
index 0000000..82190db
--- /dev/null
+++ b/parse/err.c
@@ -0,0 +1,53 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <string.h>
+#include <assert.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "util.h"
+#include "parse.h"
+
+/* errors */
+void die(char *msg, ...)
+{
+ va_list ap;
+
+ va_start(ap, msg);
+ vfprintf(stderr, msg, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+ abort();
+}
+
+void fatal(Node *n, char *msg, ...)
+{
+ va_list ap;
+
+ va_start(ap, msg);
+ lfatalv(n->loc, msg, ap);
+ va_end(ap);
+}
+
+void lfatal(Srcloc l, char *msg, ...)
+{
+ va_list ap;
+
+ va_start(ap, msg);
+ lfatalv(l, msg, ap);
+ va_end(ap);
+}
+
+void lfatalv(Srcloc l, char *msg, va_list ap)
+{
+ fprintf(stdout, "%s:%d: ", fname(l), lnum(l));
+ vfprintf(stdout, msg, ap);
+ fprintf(stdout, "\n");
+ exit(1);
+}