mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-10-01 10:54:56 +00:00
Refactor: Combined function pvarsz() into addvar()
This commit is contained in:
parent
52f54f88c9
commit
d6bff15152
34
vars.c
34
vars.c
@ -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);
|
||||||
|
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
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user