1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2026-04-19 19:16:37 +00:00

Modified First CASE logic

This commit is contained in:
Curtis F Kaylor
2018-02-13 18:26:57 -05:00
parent bb575122ca
commit 2d01054cf3
3 changed files with 11 additions and 6 deletions
+6 -1
View File
@@ -45,6 +45,7 @@ void init()
vrwrtn = FALSE;
zpaddr = 0;
invasc = FALSE;
fcase = FALSE;
}
/* Reads and parses the next Word in Source File */
@@ -54,8 +55,12 @@ void pword()
getwrd();
ACMNT(word);
DEBUG("Parsing Word '%s'\n", word);
if (xstmnt[0] && !wordis(xstmnt))
if (xstmnt[0]) {
if (wordis(xstmnt))
xstmnt[0] = 0; //Clear xstmnt
else
ERROR("Expected '%s' statement\n", xstmnt, EXIT_FAILURE);
}
if (!pmodfr() && !ptype(MTNONE))
pstmnt(); //Parse Statement
}
+1
View File
@@ -56,6 +56,7 @@ char inpnam[FNAMLEN]; //Include File Name
int alcvar; //Allocate Variables Flag
int inblck; //Multiline Block Flag
int lsrtrn; //Last Statement was a Return
int fcase; //First Case Statement
void exterr(int errnum); //Print current file name & position and exit
void expctd(char *expected); //Print Expected message and exit
+4 -5
View File
@@ -323,8 +323,9 @@ void pslct() {
expect('(');
prsxpr(')'); //Parse Expression
newlbl(endlbl); //Create New Label
pshlbl(LTSLCT,endlbl); //Push Onto Stack
pshlbl(LTSLCT,endlbl); //Push Onto Stack
bgnblk('{'); //Require Beginning of Block
fcase = TRUE;
strcpy(xstmnt, "CASE"); //Require Next Statement to be CASE
}
@@ -341,10 +342,7 @@ void ecase() {
/* parse and compile select statement */
void pcase() {
int fcase = (strcmp(xstmnt, "CASE") == 0);
if (fcase)
xstmnt[0] = 0; //Clear xstmnt
else
if (!fcase)
ecase("CASE"); //Process end of case block
skplbl[0] = 0; //Clear Skip Label
newlbl(cndlbl); //Create Conditional Label
@@ -365,6 +363,7 @@ void pcase() {
}
if (skplbl[0])
setlbl(skplbl); //Set CASE block label if defined
fcase = FALSE;
}
/* parse and compile default statement */