mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-11-22 01:31:33 +00:00
Allow expressions in second and third function argument
This commit is contained in:
parent
223f7bbb97
commit
6703c8cb10
37
src/expr.c
37
src/expr.c
@ -118,7 +118,7 @@ int prstrm(int alwint) {
|
||||
prsval(FALSE, TRUE); //Parse Value - Disallow Registers, Allow Constants
|
||||
if (valtyp == FUNCTION) ERROR("Function call only allowed in first term\n", 0, EXIT_FAILURE)
|
||||
strcpy(term, value);
|
||||
if (valtyp == VARIABLE && prcvar(alwint)) return TRUE;
|
||||
if (valtyp == VARIABLE && prcivr(alwint)) return TRUE;
|
||||
DEBUG("Parsed term %s\n", term)
|
||||
chkidx(); //Check for Array Index
|
||||
skpspc();
|
||||
@ -204,21 +204,42 @@ void prsbop(void) {
|
||||
|
||||
/* Parse Function Argument or Return Values */
|
||||
void prsfpr(char trmntr) {
|
||||
int pusha = 0; int pushy = 0; //A and Y Arguments Pushed
|
||||
if (!chkadr(ADLDYX, TRUE) && isxpre() || match('.')) {
|
||||
if (!look('.')) {if (prsxpf(0)) goto prsfne;}
|
||||
if (look('.')) pusha = 255;
|
||||
else {if (prsxpf(0)) goto prsfne;}
|
||||
if (look(',') && !chkadr(ADLDYX, TRUE)) {
|
||||
if (!look('.')) {
|
||||
if (look('.')) {
|
||||
pushy = -1;
|
||||
}
|
||||
else {
|
||||
if (look('(')) {
|
||||
if (pusha==0) {pusha = 1; asmlin("PHA","");} //Save A on Stack
|
||||
prsxpr(')'); asmlin("TAY", ""); //Evaluate Expression, and Copy to Y
|
||||
}
|
||||
else {
|
||||
if (prstrm(TRUE)) goto prsfne;
|
||||
asmlin("LDY", term);
|
||||
}
|
||||
}
|
||||
if (look(',')) {
|
||||
if (look('(')) {
|
||||
if (pusha==0) {pusha = 1; asmlin("PHA","");} //Save A on Stack
|
||||
if (pushy==0) {pushy = 1; asmlin("PHA",""); asmlin("PHY","");} //Save Y on Stack
|
||||
prsxpr(')'); asmlin("TAX", ""); //Evaluate Expression, and Copy to X
|
||||
}
|
||||
else {
|
||||
prsval(FALSE, TRUE); //Parse Value - Disallow Registers, Allow Constants
|
||||
if (valtyp > VARIABLE) ERROR("Illegal Value Function Argument\n", 0, EXIT_FAILURE);
|
||||
if (valtyp == VARIABLE && vartyp != VTCHAR) ERROR("Illegal Variable Type\n", 0, EXIT_FAILURE);
|
||||
asmlin("LDX", value); }
|
||||
asmlin("LDX", value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
prsfne:
|
||||
if (pushy==1) {asmlin("PLA",""); asmlin("TAY","");} //Pull Y Off Stack
|
||||
if (pusha==1) asmlin("PLA",""); //Pull A Off Stack
|
||||
expect(trmntr);
|
||||
}
|
||||
|
||||
@ -244,8 +265,10 @@ void prcvri(void) {
|
||||
asmlin("LDY", value);
|
||||
}
|
||||
|
||||
/* Process Variable in Term */
|
||||
int prcvar(int alwint) {
|
||||
/* Process Integer Variable in Term *
|
||||
* Args: alwint = Allow Integer-Like Variable *
|
||||
* Returns: Integer-Like Variable Processed - TRUE/FALSE */
|
||||
int prcivr(int alwint) {
|
||||
switch (vartyp) {
|
||||
case VTINT:
|
||||
if (!alwint) ERROR("Illegal Use of Integer Variable %s\n", word, EXIT_FAILURE)
|
||||
@ -268,7 +291,7 @@ int prcvar(int alwint) {
|
||||
int prcftm(int alwint) {
|
||||
DEBUG("Processing first term '%s'\n", value)
|
||||
strcpy(term, value);
|
||||
if (valtyp == VARIABLE && prcvar(alwint)) return TRUE;
|
||||
if (valtyp == VARIABLE && prcivr(alwint)) return TRUE;
|
||||
if (valtyp == FUNCTION) prsfnc(0); //Parse Expression Function
|
||||
else if (wordis("A")) return FALSE;
|
||||
else if (wordis("X")) asmlin("TXA", "");
|
||||
|
@ -16,7 +16,7 @@ int chkadr(int adract, int alwstr); //Check for and Process Address or String
|
||||
void chkidx(); //Check for, Parse, and Process Index
|
||||
int prcftm(int alwint); //Process First Term
|
||||
void prcvri(void); //Process Integer Variable
|
||||
int prcvar(int alwint); //Process Variable in Term
|
||||
int prcivr(int alwint); //Process Integer Variable in Term
|
||||
void prsadr(int adract); //Parse and Compile Address of Operator
|
||||
void prsbop(void); //Parse Byte Operator
|
||||
void prsval(int alwreg, int alwcon); //Parse Value
|
||||
|
Loading…
Reference in New Issue
Block a user