ref: 592e9b372509c306b1c4346665799f68bf00cec4
parent: effc58241df9802e51c1eab91351a70ffe42b40b
author: ISSOtm <eldredhabert0@gmail.com>
date: Fri Jan 22 06:09:27 EST 2021
Reorganize and comment better `main()`
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -337,19 +337,25 @@
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;
--- a/src/asm/section.c
+++ b/src/asm/section.c
@@ -488,7 +488,7 @@
void sect_CheckUnionClosed(void)
{
if (unionStack)
- fatalerror("Unterminated UNION construct!\n");
+ error("Unterminated UNION construct!\n");
}
/*