diff --git a/src/asm/main.c b/src/asm/main.c index ea060a72..3bd1e62f 100644 --- a/src/asm/main.c +++ b/src/asm/main.c @@ -337,19 +337,25 @@ int main(int argc, char *argv[]) fprintf(dependfile, "%s: %s\n", tzTargetFileName, mainFileName); } - /* Init file stack; important to do first, since it provides the file name, line, etc */ + charmap_New("main", NULL); + + // Init lexer and file stack, prodiving file info lexer_Init(); fstk_Init(mainFileName, maxRecursionDepth); - charmap_New("main", NULL); + // Perform parse (yyparse is auto-generated from `parser.y`) + if (yyparse() != 0 && nbErrors == 0) + nbErrors = 1; - if (yyparse() != 0 || nbErrors != 0) - errx(1, "Assembly aborted (%u errors)!", nbErrors); if (dependfile) fclose(dependfile); sect_CheckUnionClosed(); + if (nbErrors != 0) + errx(1, "Assembly aborted (%u errors)!", nbErrors); + + // If parse aborted due to missing an include, and `-MG` was given, exit normally if (oFailedOnMissingInclude) return 0; diff --git a/src/asm/section.c b/src/asm/section.c index f381b786..a8d0746f 100644 --- a/src/asm/section.c +++ b/src/asm/section.c @@ -488,7 +488,7 @@ void sect_EndUnion(void) void sect_CheckUnionClosed(void) { if (unionStack) - fatalerror("Unterminated UNION construct!\n"); + error("Unterminated UNION construct!\n"); } /*