1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-06-08 21:29:30 +00:00

Bug Fx: Modified bgnblk() and added to call when parsing CASE

This commit is contained in:
Curtis F Kaylor 2018-02-06 22:50:50 -05:00
parent 9c49c61d44
commit 68aa3c1a8f
5 changed files with 26 additions and 8 deletions

BIN
c02.exe

Binary file not shown.

BIN
c02.tag

Binary file not shown.

View File

@ -9,7 +9,7 @@ char c;
main:
for (c=0; c<=9; c++) {
for (c=0; c<10; c++) {
prbyte(c);
putc(' ');
select (c) {
@ -24,7 +24,7 @@ for (c=0; c<=9; c++) {
}
newlin();
for (c=0; c<=9; c++) {
for (c=0; c<10; c++) {
prbyte(c);
putc(' ');
select (c) {
@ -38,4 +38,20 @@ for (c=0; c<=9; c++) {
}
}
newlin();
for (c=$18; c<$23; c++) {
prbyte(c);
putc(' ');
select (c) {
case $18: putln("I'M EIGHTEEN!");
case $19:
putln("BREAK ONE-NINE");
if (c==$19) break;
putln("OOPS!");
case $22: putln("BLACKJACK!");
default: //putln("*");
}
}
goto exit;

12
stmnt.c
View File

@ -92,11 +92,11 @@ void prcvar(char trmntr)
}
/* Begin Program Block */
void bgnblk(int blkflg)
void bgnblk(char blkchr)
{
DEBUG("Begining program block\n", 0);
if (blkflg) {
expect('{');
if (blkchr) {
expect(blkchr);
inblck = TRUE;
}
else
@ -313,12 +313,13 @@ void pslct() {
prsxpr(')'); //Parse Expression
newlbl(endlbl); //Create New Label
pshlbl(LTSLCT,endlbl); //Push Onto Stack
bgnblk(TRUE); //Check For and Begin Block
bgnblk('{'); //Require Beginning of Block
strcpy(xstmnt, "CASE"); //Require Next Statement to be CASE
}
/* process end of case block */
void ecase() {
DEBUG("Processing end of CASE block\n", 0);
if (poplbl(cndlbl) != LTCASE)
ERROR("%s not at end of CASE block\n", word, EXIT_FAILURE);
if (toplbl(endlbl) != LTSLCT)
@ -347,7 +348,7 @@ void pcase() {
fcase = 0;
continue; //Parse next argument
}
expect(':'); //Emit branch to end of CASE block
bgnblk(':'); //Emit branch to end of CASE block
asmlin("BNE", cndlbl);
break;
}
@ -481,6 +482,7 @@ void pstmnt()
else
prssym();
if (lblcnt && !inblck) {
DEBUG("Ending implied block\n", 0);
if (poplbl() == LTDO)
pdowhl(); //Parse While at End of Do Loop
}

2
vars.c
View File

@ -233,7 +233,7 @@ void addfnc()
asmlin("STX", prmtrx); //Store Third Parameter
endlbl[0] = 0; //Create Dummy End Label
pshlbl(LTFUNC, endlbl); //and Push onto Stack
bgnblk(TRUE); //Start Program Block
bgnblk('{'); //Start Program Block
}
/* (Check For and) Parse Variable Declaration*/