ref: cd2af0204e6854baa9ac86d497e423a29994c5f8
parent: 91241b44daebcf120aa9ffb858bb855e485ae410
author: Anthony J. Bentley <[email protected]>
date: Thu Jan 22 15:33:07 EST 2015
rgbasm: Save some horizontal space in main.c.
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -323,6 +323,7 @@
nErrors = 0;
sym_PrepPass1();
fstk_Init(tzMainfile);
+
if (CurrentOptions.verbose) {
printf("Pass 1...\n");
}
@@ -330,58 +331,48 @@
yy_set_state(LEX_STATE_NORMAL);
opt_SetCurrentOptions(&DefaultOptions);
- if (yyparse() == 0 && nErrors == 0) {
- if (nIFDepth == 0) {
- nTotalLines = 0;
- nLineNo = 1;
- nIFDepth = 0;
- nPC = 0;
- nPass = 2;
- nErrors = 0;
- sym_PrepPass2();
- out_PrepPass2();
- fstk_Init(tzMainfile);
- yy_set_state(LEX_STATE_NORMAL);
- opt_SetCurrentOptions(&DefaultOptions);
+ if (yyparse() != 0 || nErrors != 0) {
+ errx(1, "Assembly aborted in pass 1 (%ld errors)!", nErrors);
+ }
- if (CurrentOptions.verbose) {
- printf("Pass 2...\n");
- }
+ if (nIFDepth != 0) {
+ errx(1, "Unterminated IF construct (%ld levels)!", nIFDepth);
+ }
- if (yyparse() == 0 && nErrors == 0) {
- double timespent;
+ nTotalLines = 0;
+ nLineNo = 1;
+ nIFDepth = 0;
+ nPC = 0;
+ nPass = 2;
+ nErrors = 0;
+ sym_PrepPass2();
+ out_PrepPass2();
+ fstk_Init(tzMainfile);
+ yy_set_state(LEX_STATE_NORMAL);
+ opt_SetCurrentOptions(&DefaultOptions);
- nEndClock = clock();
- timespent =
- ((double) (nEndClock - nStartClock))
- / (double) CLOCKS_PER_SEC;
- if (CurrentOptions.verbose) {
- printf
- ("Success! %ld lines in %d.%02d seconds ",
- nTotalLines, (int) timespent,
- ((int) (timespent * 100.0)) % 100);
- if (timespent == 0)
- printf
- ("(INFINITY lines/minute)\n");
- else
- printf("(%d lines/minute)\n",
- (int) (60 / timespent *
- nTotalLines));
- }
- out_WriteObject();
- } else {
- printf
- ("Assembly aborted in pass 2 (%ld errors)!\n",
- nErrors);
- exit(5);
- }
- } else {
- errx(1, "Unterminated IF construct (%ld levels)!",
- nIFDepth);
- }
- } else {
- errx(1, "Assembly aborted in pass 1 (%ld errors)!",
- nErrors);
+ if (CurrentOptions.verbose) {
+ printf("Pass 2...\n");
}
+
+ if (yyparse() != 0 || nErrors != 0) {
+ errx(1, "Assembly aborted in pass 2 (%ld errors)!", nErrors);
+ }
+
+ double timespent;
+
+ nEndClock = clock();
+ timespent = ((double)(nEndClock - nStartClock))
+ / (double)CLOCKS_PER_SEC;
+ if (CurrentOptions.verbose) {
+ printf("Success! %ld lines in %d.%02d seconds ", nTotalLines,
+ (int) timespent, ((int) (timespent * 100.0)) % 100);
+ if (timespent == 0)
+ printf("(INFINITY lines/minute)\n");
+ else
+ printf("(%d lines/minute)\n",
+ (int) (60 / timespent * nTotalLines));
+ }
+ out_WriteObject();
return 0;
}