mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-06-26 05:29:32 +00:00
Modified First CASE logic
This commit is contained in:
parent
bb575122ca
commit
2d01054cf3
7
c02.c
7
c02.c
|
@ -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
common.h
1
common.h
|
@ -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
|
||||
|
|
9
stmnt.c
9
stmnt.c
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue
Block a user