aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-14 02:38:59 +1300
committerAndrew Chambers <[email protected]>2021-10-14 02:38:59 +1300
commitbc8b406043b23a5825320248cbad3ff73cd124fe (patch)
tree0b20398d179622e1fb106e3138539187cadb28c1 /main.c
parent3964d1dc536bce2e7da15569b42e9ad1c7258d78 (diff)
Minor refactor.
Diffstat (limited to 'main.c')
-rw-r--r--main.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/main.c b/main.c
index bc67bb6..395b5f6 100644
--- a/main.c
+++ b/main.c
@@ -27,8 +27,18 @@ static Section *data = NULL;
static Section *textrel = NULL;
static Section *datarel = NULL;
+char *filename = "<stdin>";
size_t curlineno = 0;
+void lfatal(const char *fmt, ...) {
+ va_list ap;
+ fprintf(stderr, "%s:%ld: ", filename, curlineno);
+ va_start(ap, fmt);
+ vwarn(fmt, ap);
+ va_end(ap);
+ exit(1);
+}
+
static Symbol *getsym(const char *name) {
Symbol **ps, *s;
struct hashtablekey htk;
@@ -639,6 +649,9 @@ static void assemble(void) {
curlineno++;
v = l->v;
switch (v->kind) {
+ case ASM_SYNTAX_ERROR:
+ lfatal("syntax error");
+ break;
case ASM_BLANK:
break;
case ASM_DIR_GLOBL: