aboutsummaryrefslogtreecommitdiff
path: root/cup/utils.c
diff options
context:
space:
mode:
authorMustafa Quraish <[email protected]>2022-01-24 11:41:31 -0500
committerMustafa Quraish <[email protected]>2022-01-24 11:41:31 -0500
commit8fdfe1150a2155da5ea9d458adc347c4a6de5ce1 (patch)
treee0383491fac4c2d9f65799270fba4e596f8852aa /cup/utils.c
downloadarchived-cup-8fdfe1150a2155da5ea9d458adc347c4a6de5ce1.tar.xz
archived-cup-8fdfe1150a2155da5ea9d458adc347c4a6de5ce1.zip
Initial commit + start of lexer
Diffstat (limited to 'cup/utils.c')
-rw-r--r--cup/utils.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/cup/utils.c b/cup/utils.c
new file mode 100644
index 0000000..3a586cd
--- /dev/null
+++ b/cup/utils.c
@@ -0,0 +1,24 @@
+#include "utils.h"
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+void die(const char *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+ exit(1);
+}
+
+void die_location(Location loc, const char *fmt, ...)
+{
+ Location_print(stderr, loc);
+ va_list args;
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+ exit(1);
+} \ No newline at end of file