mirror of
https://github.com/RevCurtisP/C02.git
synced 2025-02-16 14:30:33 +00:00
Fixed chained IF/ELSE statements
This commit is contained in:
parent
5bfaa05718
commit
8e49f69a9e
@ -39,7 +39,7 @@ int enccmp(char c) {
|
||||
* Uses: term - Term Being Compared Against *
|
||||
* label - Branch Target if Comparison is FALSE */
|
||||
void prccmp(void) {
|
||||
DEBUG("Processing comparitor %d\n", cmprtr)
|
||||
DEBUG("Processing comparator %d\n", cmprtr)
|
||||
switch(cmprtr) {
|
||||
case 0: // Raw Expression (Skip)
|
||||
asmlin("BEQ", cndlbl); break;
|
||||
@ -93,10 +93,10 @@ void prsflg(int revrse) {
|
||||
/* Parse and Compile Conditional Expression *
|
||||
* Condition = <expression> <comparator> <term> */
|
||||
void prscnd(char trmntr, int revrse) {
|
||||
DEBUG("Parsing condition with revrse=%d\n", revrse)
|
||||
DEBUG("Parsing condition with REVRSE=%d\n", revrse)
|
||||
if (look('!')) {
|
||||
revrse = (revrse) ? FALSE: TRUE;
|
||||
DEBUG("Set revrse to %d\n", revrse)
|
||||
DEBUG("Set REVRSE to %d\n", revrse)
|
||||
}
|
||||
if (!look('*')) prsxpr(0);
|
||||
if (look(':')) prsflg(revrse); //Parse Flag Operator
|
||||
|
@ -16,7 +16,7 @@ int lblcnt; //Number of Labels in stack
|
||||
int lblnxt; //Sequence of next label to be generated
|
||||
char lbltmp[LABLEN+1]; //Label Temporary Storage
|
||||
|
||||
enum ltypes {LTNONE, LTIF, LTLOOP, LTEND, LTDO, LTDWHL, LTSLCT, LTCASE, LTFUNC}; //Label Types
|
||||
enum ltypes {LTNONE, LTIF, LTELSE, LTLOOP, LTEND, LTDO, LTDWHL, LTSLCT, LTCASE, LTFUNC}; //Label Types
|
||||
enum lflags {LFNONE, LFBGN, LFEND}; //Label Flag Types
|
||||
|
||||
void chklbl(char* lbname); //Check Label Contents
|
||||
|
10
src/stmnt.c
10
src/stmnt.c
@ -19,14 +19,14 @@
|
||||
|
||||
/* Begin Program Block */
|
||||
void bgnblk(char blkchr) {
|
||||
DEBUG("Begining program block\n", 0)
|
||||
DEBUG("Beginning program block\n", 0)
|
||||
if (blkchr) {
|
||||
expect(blkchr);
|
||||
inblck = TRUE;
|
||||
}
|
||||
else
|
||||
inblck = look('{');
|
||||
DEBUG("Set inblck to %d\n", inblck)
|
||||
DEBUG("Set INBLCK to %d\n", inblck)
|
||||
setblk(inblck);
|
||||
}
|
||||
|
||||
@ -238,8 +238,10 @@ void pelse(void) {
|
||||
DEBUG("Parsing ELSE statement\n", 0)
|
||||
strcpy(lbltmp, lblasm); //Save Line Label
|
||||
lblasm[0] = 0; //and Clear It
|
||||
newlbl(skplbl); //Create Skip Label
|
||||
pshlbl(LTIF, skplbl); //Push Onto Stack
|
||||
if (toplbl(skplbl) != LTELSE) { //Get Chained ELSE Label or
|
||||
newlbl(skplbl); //Create Skip Label
|
||||
pshlbl(LTELSE, skplbl); //Push Onto Stack
|
||||
}
|
||||
asmlin("JMP", skplbl); //Emit Jump over Block Code
|
||||
strcpy(lblasm, lbltmp); //Restore Line Label
|
||||
bgnblk(FALSE); //Check For and Begin Block
|
||||
|
Loading…
x
Reference in New Issue
Block a user