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

Refactor: Combined function pvarsz() into addvar()

This commit is contained in:
Curtis F Kaylor 2018-02-08 23:07:04 -05:00
parent 52f54f88c9
commit d6bff15152

36
vars.c
View File

@ -55,25 +55,6 @@ void reqvar(int alwary)
expctd("Variable"); expctd("Variable");
} }
/* Check for Array specifier and get size *
* Sets: value - array size (as string) *
* "" if not an array */
void pvarsz()
{
DEBUG("Checking for array definition\n", 0);
value[0] = 0;
if (match('[')) {
skpchr();
if (alcvar) {
DEBUG("Parsing array size\n", 0);
sprintf(value, "%d", prsnum(0xFF) + 1);
}
expect(']');
}
if (!alcvar)
strcpy(value, "*");
}
/* Parse Data Constant */ /* Parse Data Constant */
void prsdtc() void prsdtc()
{ {
@ -181,9 +162,20 @@ void addvar(int m, int t)
asmlin(EQUOP, word); asmlin(EQUOP, word);
strcpy(value, "*"); //Set Variable Type to Zero Page strcpy(value, "*"); //Set Variable Type to Zero Page
} }
else else {
pvarsz(); //Check for Array Declaration and Get Size DEBUG("Checking for array definition\n", 0);
setvar(m, t); //Add to Variable Table value[0] = 0;
if (match('[')) {
skpchr();
if (alcvar) {
DEBUG("Parsing array size\n", 0);
sprintf(value, "%d", prsnum(0xFF) + 1);
}
expect(']');
}
if (!alcvar) strcpy(value, "*");
setvar(m, t); //Add to Variable Table
}
if (m != MTZP) if (m != MTZP)
prsdat(); //Parse Variable Data prsdat(); //Parse Variable Data
varcnt++; //Increment Variable Counter varcnt++; //Increment Variable Counter