1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-06-28 19:29:39 +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");
}
/* 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 */
void prsdtc()
{
@ -181,9 +162,20 @@ void addvar(int m, int t)
asmlin(EQUOP, word);
strcpy(value, "*"); //Set Variable Type to Zero Page
}
else
pvarsz(); //Check for Array Declaration and Get Size
setvar(m, t); //Add to Variable Table
else {
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, "*");
setvar(m, t); //Add to Variable Table
}
if (m != MTZP)
prsdat(); //Parse Variable Data
varcnt++; //Increment Variable Counter