mirror of
https://github.com/RevCurtisP/C02.git
synced 2025-02-16 14:30:33 +00:00
Added function name to all debug output in expr.c and parse.c
This commit is contained in:
parent
e284bebbfb
commit
31622c3480
32
src/expr.c
32
src/expr.c
@ -52,7 +52,7 @@ void prsval(int alwreg, int alwcon) {
|
|||||||
|
|
||||||
/* Process Unary Minus */
|
/* Process Unary Minus */
|
||||||
void prcmns(void) {
|
void prcmns(void) {
|
||||||
DEBUG("Processing unary minus", 0)
|
DEBUG("expr.prcmns: Processing unary minus", 0)
|
||||||
asmlin("LDA", "#$00"); //Handle Unary Minus
|
asmlin("LDA", "#$00"); //Handle Unary Minus
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ void prcxix(void) {
|
|||||||
|
|
||||||
/* Check for, Parse, and Process Index */
|
/* Check for, Parse, and Process Index */
|
||||||
void chkidx(void) {
|
void chkidx(void) {
|
||||||
//DEBUG("Checking for Array Index with valtyp=%d\n", valtyp)
|
//DEBUG("expr.chkidx: Checking for Array Index with valtyp=%d\n", valtyp)
|
||||||
if (valtyp == ARRAY) {
|
if (valtyp == ARRAY) {
|
||||||
if (look('-')) {
|
if (look('-')) {
|
||||||
prcmns();
|
prcmns();
|
||||||
@ -123,7 +123,7 @@ void chkidx(void) {
|
|||||||
/* Parse Pointer *
|
/* Parse Pointer *
|
||||||
* Sets: term - Compiled Pointer */
|
* Sets: term - Compiled Pointer */
|
||||||
void prsptr(void) {
|
void prsptr(void) {
|
||||||
DEBUG("Parsing pointer\n", 0)
|
DEBUG("expr.prsptr: Parsing pointer\n", 0)
|
||||||
expect('*'); //Pointer Dereference Operator
|
expect('*'); //Pointer Dereference Operator
|
||||||
prsvar(FALSE,FALSE); //Parse Variable to Dereference
|
prsvar(FALSE,FALSE); //Parse Variable to Dereference
|
||||||
strcpy(term, value);
|
strcpy(term, value);
|
||||||
@ -165,7 +165,7 @@ int prcptr(void) {
|
|||||||
* Sets: term - the term (as a string) *
|
* Sets: term - the term (as a string) *
|
||||||
* Returns: TRUE if term is an integer */
|
* Returns: TRUE if term is an integer */
|
||||||
int prstrm(int alwint) {
|
int prstrm(int alwint) {
|
||||||
DEBUG("Parsing term\n", 0)
|
DEBUG("expr.prstrm: Parsing term\n", 0)
|
||||||
if (match('*')) return prcptr(); //Parse and Deference Pointer
|
if (match('*')) return prcptr(); //Parse and Deference Pointer
|
||||||
prsval(FALSE, TRUE); //Parse Value - Disallow Registers, Allow Constants
|
prsval(FALSE, TRUE); //Parse Value - Disallow Registers, Allow Constants
|
||||||
if (valtyp == FUNCTION) ERROR("Function call only allowed in first term\n", 0, EXIT_FAILURE)
|
if (valtyp == FUNCTION) ERROR("Function call only allowed in first term\n", 0, EXIT_FAILURE)
|
||||||
@ -181,7 +181,7 @@ int prstrm(int alwint) {
|
|||||||
* Args: adract = Address Action (adacts) *
|
* Args: adract = Address Action (adacts) *
|
||||||
* symbol = Symbol to Process */
|
* symbol = Symbol to Process */
|
||||||
void prcadr(int adract, char* symbol) {
|
void prcadr(int adract, char* symbol) {
|
||||||
DEBUG("Processing address '%s'\n", word)
|
DEBUG("expr.prcadr: Processing address '%s'\n", word)
|
||||||
strcpy(word,"#>(");
|
strcpy(word,"#>(");
|
||||||
strcat(word,symbol);
|
strcat(word,symbol);
|
||||||
strcat(word,")");
|
strcat(word,")");
|
||||||
@ -213,7 +213,7 @@ void prsadr(int adract) {
|
|||||||
* alwstr = Allow String */
|
* alwstr = Allow String */
|
||||||
void prsstr(int adract, int alwstr) {
|
void prsstr(int adract, int alwstr) {
|
||||||
if (!alwstr) ERROR("Illegal String Reference", 0, EXIT_FAILURE)
|
if (!alwstr) ERROR("Illegal String Reference", 0, EXIT_FAILURE)
|
||||||
DEBUG("Parsing anonymous string\n", 0)
|
DEBUG("expr.prsstr: Parsing anonymous string\n", 0)
|
||||||
newlbl(vrname); //Generate Variable Name
|
newlbl(vrname); //Generate Variable Name
|
||||||
value[0] = 0; //Use Variable Size 0
|
value[0] = 0; //Use Variable Size 0
|
||||||
setvar(MTNONE, VTCHAR); //Set Variable Name, Type, and Size
|
setvar(MTNONE, VTCHAR); //Set Variable Name, Type, and Size
|
||||||
@ -241,7 +241,7 @@ int chkadr(int adract, int alwstr) {
|
|||||||
void prsbop(void) {
|
void prsbop(void) {
|
||||||
char byteop = getnxt();
|
char byteop = getnxt();
|
||||||
CCMNT(byteop);
|
CCMNT(byteop);
|
||||||
DEBUG("Parsing byte operator '%c'\n", byteop)
|
DEBUG("expr.prsbop: Parsing byte operator '%c'\n", byteop)
|
||||||
if (chkadr(FALSE, FALSE)) {
|
if (chkadr(FALSE, FALSE)) {
|
||||||
sprintf(value, "%c(%s)", byteop, word);
|
sprintf(value, "%c(%s)", byteop, word);
|
||||||
valtyp = LITERAL;
|
valtyp = LITERAL;
|
||||||
@ -251,7 +251,7 @@ void prsbop(void) {
|
|||||||
if (byteop == '>') strcat(value, "+1");
|
if (byteop == '>') strcat(value, "+1");
|
||||||
vartyp = VTCHAR;
|
vartyp = VTCHAR;
|
||||||
}
|
}
|
||||||
DEBUG("Set value to \"%s\"\n", value)
|
DEBUG("expr.prsbop: Set value to \"%s\"\n", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Parse Function Argument or Return Values */
|
/* Parse Function Argument or Return Values */
|
||||||
@ -299,7 +299,7 @@ void prsfpr(char trmntr) {
|
|||||||
|
|
||||||
/* Parse function call */
|
/* Parse function call */
|
||||||
void prsfnc(char trmntr) {
|
void prsfnc(char trmntr) {
|
||||||
DEBUG("Processing Function Call '%s'\n", term)
|
DEBUG("expr.prsfnc: Processing Function Call '%s'\n", term)
|
||||||
//int argexp = FALSE; //Expression(s) in second and third argument
|
//int argexp = FALSE; //Expression(s) in second and third argument
|
||||||
pshtrm(); //Push Function Name onto Term Stack
|
pshtrm(); //Push Function Name onto Term Stack
|
||||||
skpchr(); //skip open paren
|
skpchr(); //skip open paren
|
||||||
@ -313,7 +313,7 @@ void prsfnc(char trmntr) {
|
|||||||
|
|
||||||
/* Process Integer Variable */
|
/* Process Integer Variable */
|
||||||
void prcvri(void) {
|
void prcvri(void) {
|
||||||
DEBUG("Processing Integer Variable '%s'\n", value)
|
DEBUG("expr.prcvri: Processing Integer Variable '%s'\n", value)
|
||||||
asmlin("LDX", value);
|
asmlin("LDX", value);
|
||||||
strcat(value, "+1");
|
strcat(value, "+1");
|
||||||
asmlin("LDY", value);
|
asmlin("LDY", value);
|
||||||
@ -343,7 +343,7 @@ int prcivr(int alwint) {
|
|||||||
|
|
||||||
/* Process first term of expression */
|
/* Process first term of expression */
|
||||||
int prcftm(int alwint) {
|
int prcftm(int alwint) {
|
||||||
DEBUG("Processing first term '%s'\n", value)
|
DEBUG("expr.prcftm: Processing first term '%s'\n", value)
|
||||||
strcpy(term, value);
|
strcpy(term, value);
|
||||||
if (valtyp == VARIABLE && prcivr(alwint)) return TRUE;
|
if (valtyp == VARIABLE && prcivr(alwint)) return TRUE;
|
||||||
if (valtyp == FUNCTION) prsfnc(0); //Parse Expression Function
|
if (valtyp == FUNCTION) prsfnc(0); //Parse Expression Function
|
||||||
@ -357,7 +357,7 @@ int prcftm(int alwint) {
|
|||||||
/* Parse first term of expession *
|
/* Parse first term of expession *
|
||||||
* First term can include function calls */
|
* First term can include function calls */
|
||||||
int prsftm(int alwint) {
|
int prsftm(int alwint) {
|
||||||
DEBUG("Parsing first term\n", 0)
|
DEBUG("expr.prsftm: Parsing first term\n", 0)
|
||||||
if (match('*')) {
|
if (match('*')) {
|
||||||
prcptr(); //Parse and Deference Pointer
|
prcptr(); //Parse and Deference Pointer
|
||||||
asmlin("LDA", term);
|
asmlin("LDA", term);
|
||||||
@ -370,7 +370,7 @@ int prsftm(int alwint) {
|
|||||||
/* Process Arithmetic or Bitwise Operator *
|
/* Process Arithmetic or Bitwise Operator *
|
||||||
* and the term that follows it */
|
* and the term that follows it */
|
||||||
void prcopr(void) {
|
void prcopr(void) {
|
||||||
DEBUG("Processing operator '%c'\n", oper)
|
DEBUG("expr.prcopr: Processing operator '%c'\n", oper)
|
||||||
switch(oper) {
|
switch(oper) {
|
||||||
case '+': asmlin("CLC", ""); asmlin("ADC", term); break; //Addition
|
case '+': asmlin("CLC", ""); asmlin("ADC", term); break; //Addition
|
||||||
case '-': asmlin("SEC", ""); asmlin("SBC", term); break; //Subtraction
|
case '-': asmlin("SEC", ""); asmlin("SBC", term); break; //Subtraction
|
||||||
@ -397,7 +397,7 @@ void prsrxp(char trmntr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int prsxpp(char trmntr, int alwint) {
|
int prsxpp(char trmntr, int alwint) {
|
||||||
DEBUG("Parsing expression\n", 0)
|
DEBUG("expr.prsxpp: Parsing expression\n", 0)
|
||||||
skpspc();
|
skpspc();
|
||||||
trmcnt = 0; //Initialize Expression Depth
|
trmcnt = 0; //Initialize Expression Depth
|
||||||
if (match('-')) prcmns(); //Process Unary Minus
|
if (match('-')) prcmns(); //Process Unary Minus
|
||||||
@ -426,10 +426,10 @@ int prsxpf(char trmntr) {
|
|||||||
* Sets: value - Parsed Value or Symbol */
|
* Sets: value - Parsed Value or Symbol */
|
||||||
void prsxpi(char trmntr, int asmxpr) {
|
void prsxpi(char trmntr, int asmxpr) {
|
||||||
skpspc();
|
skpspc();
|
||||||
DEBUG("Parsing integer expression\n", 0)
|
DEBUG("expr.prsxpi: Parsing integer expression\n", 0)
|
||||||
if (!chkadr(TRUE, FALSE)) {
|
if (!chkadr(TRUE, FALSE)) {
|
||||||
if (isnpre()) {
|
if (isnpre()) {
|
||||||
DEBUG("Parsing Integer Literal\n", 0)
|
DEBUG("expr.prsxpi: Parsing Integer Literal\n", 0)
|
||||||
int number = prsnum(0xFFFF); //Parse Number into value
|
int number = prsnum(0xFFFF); //Parse Number into value
|
||||||
if (asmxpr) {
|
if (asmxpr) {
|
||||||
sprintf(value, "#%d", number & 0xFF); asmlin("LDX", value);
|
sprintf(value, "#%d", number & 0xFF); asmlin("LDX", value);
|
||||||
|
30
src/parse.c
30
src/parse.c
@ -44,7 +44,7 @@ int isxpre(void) {return TF(isvpre() || match('-'));}
|
|||||||
char prcchr(char c) {
|
char prcchr(char c) {
|
||||||
if (invasc) c = isalpha(c) ? (islower(c)?toupper(c):tolower(c)) : c;
|
if (invasc) c = isalpha(c) ? (islower(c)?toupper(c):tolower(c)) : c;
|
||||||
if (mskasc) c = c | 0x80;
|
if (mskasc) c = c | 0x80;
|
||||||
if (invasc || mskasc) DEBUG("Character converted to '%c'\n", c)
|
if (invasc || mskasc) DEBUG("parse.prcchr: Character converted to '%c'\n", c)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ char getnxt(void) {
|
|||||||
|
|
||||||
/* Advance Input File to next printable character */
|
/* Advance Input File to next printable character */
|
||||||
void skpspc(void) {
|
void skpspc(void) {
|
||||||
//DEBUG("Skipping Spaces\n", 0)
|
//DEBUG("parse.skpspc: Skipping Spaces\n", 0)
|
||||||
if (isspc()) CCMNT(' '); //Add only the first space to comments
|
if (isspc()) CCMNT(' '); //Add only the first space to comments
|
||||||
while (isspc()) getnxt();
|
while (isspc()) getnxt();
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ void skpeol(void) {while (!isnl()) getnxt();}
|
|||||||
* Recognizes both C and C++ style comments */
|
* Recognizes both C and C++ style comments */
|
||||||
void skpcmt(int skslsh)
|
void skpcmt(int skslsh)
|
||||||
{
|
{
|
||||||
DEBUG("Skipping Comment\n", 0)
|
DEBUG("parse.skpcmt: Skipping Comment\n", 0)
|
||||||
if (skslsh) skpchr(); //skip initial /
|
if (skslsh) skpchr(); //skip initial /
|
||||||
if (match('/')) skpeol(); //if C style comment skip rest of line
|
if (match('/')) skpeol(); //if C style comment skip rest of line
|
||||||
else if (match('*')) //if C++ style comment
|
else if (match('*')) //if C++ style comment
|
||||||
@ -147,7 +147,7 @@ void getwrd(void) {
|
|||||||
|
|
||||||
/* Escape Character */
|
/* Escape Character */
|
||||||
char escape(char c) {
|
char escape(char c) {
|
||||||
DEBUG("Escaping character '%c'\n", c)
|
DEBUG("parse.escape: Escaping character '%c'\n", c)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'a': return 0x07; //Alert (Beep/Bell)
|
case 'a': return 0x07; //Alert (Beep/Bell)
|
||||||
case 'b': return 0x08; //Backspace
|
case 'b': return 0x08; //Backspace
|
||||||
@ -163,7 +163,7 @@ char escape(char c) {
|
|||||||
|
|
||||||
/* Escape Numeric Literal */
|
/* Escape Numeric Literal */
|
||||||
char escnum(void) {
|
char escnum(void) {
|
||||||
DEBUG("Escaping numeric literal\n", 0);
|
DEBUG("parse.escnum: Escaping numeric literal\n", 0);
|
||||||
char c = prsnum(0xff);
|
char c = prsnum(0xff);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -175,7 +175,7 @@ void getstr(void) {
|
|||||||
char strdel;
|
char strdel;
|
||||||
int escnxt = FALSE;
|
int escnxt = FALSE;
|
||||||
pstlen = 0;
|
pstlen = 0;
|
||||||
DEBUG("Parsing string\n", 0)
|
DEBUG("parse.getstr: Parsing string\n", 0)
|
||||||
strdel = getnxt(); //Get String Delimiter
|
strdel = getnxt(); //Get String Delimiter
|
||||||
CCMNT(strdel);
|
CCMNT(strdel);
|
||||||
while(!match(strdel) || escnxt) {
|
while(!match(strdel) || escnxt) {
|
||||||
@ -248,7 +248,7 @@ int prshex(void) {
|
|||||||
wrdlen = 0;
|
wrdlen = 0;
|
||||||
int digit;
|
int digit;
|
||||||
int number = 0;
|
int number = 0;
|
||||||
DEBUG("Parsing hexadecimal literal '", 0)
|
DEBUG("parse.prshex: Parsing hexadecimal literal '", 0)
|
||||||
if (!match('$')) expctd("hexadecimal number");
|
if (!match('$')) expctd("hexadecimal number");
|
||||||
word[wrdlen++] = getnxt();
|
word[wrdlen++] = getnxt();
|
||||||
while (ishexd()) {
|
while (ishexd()) {
|
||||||
@ -271,11 +271,11 @@ int prshex(void) {
|
|||||||
int prschr(void) {
|
int prschr(void) {
|
||||||
wrdlen = 0;
|
wrdlen = 0;
|
||||||
char c;
|
char c;
|
||||||
DEBUG("Parsing character literal\n", 0)
|
DEBUG("parse.prschr: Parsing character literal\n", 0)
|
||||||
word[wrdlen++] = getnxt(); //Initial Single Quote
|
word[wrdlen++] = getnxt(); //Initial Single Quote
|
||||||
if (match('\\')) word[wrdlen++] = getnxt();
|
if (match('\\')) word[wrdlen++] = getnxt();
|
||||||
c = getnxt();
|
c = getnxt();
|
||||||
DEBUG("Extracted character %c\n", c)
|
DEBUG("parse.prschr: Extracted character %c\n", c)
|
||||||
word[wrdlen++] = prcchr(c);
|
word[wrdlen++] = prcchr(c);
|
||||||
if (!match('\'')) expctd("character delimiter");
|
if (!match('\'')) expctd("character delimiter");
|
||||||
word[wrdlen++] = getnxt();
|
word[wrdlen++] = getnxt();
|
||||||
@ -298,7 +298,7 @@ int prsnum(int maxval) {
|
|||||||
case '\'': number = prschr(); break;
|
case '\'': number = prschr(); break;
|
||||||
default: number = prsdec();
|
default: number = prsdec();
|
||||||
}
|
}
|
||||||
DEBUG("Parsed number %s ", word)
|
DEBUG("parse.prsnum: Parsed number %s ", word)
|
||||||
DETAIL("with value %d\n", number)
|
DETAIL("with value %d\n", number)
|
||||||
if (number > maxval) ERROR("Out of bounds literal '%d';\n", number, EXIT_FAILURE)
|
if (number > maxval) ERROR("Out of bounds literal '%d';\n", number, EXIT_FAILURE)
|
||||||
if (maxval > 255) sprintf(value, "$%04X", number);
|
if (maxval > 255) sprintf(value, "$%04X", number);
|
||||||
@ -312,7 +312,7 @@ int prsbyt(void) {return prsnum(0xFF);}
|
|||||||
|
|
||||||
/* Find Defined Constant */
|
/* Find Defined Constant */
|
||||||
void fnddef(char *name) {
|
void fnddef(char *name) {
|
||||||
DEBUG("Looking up defined constant '%s'\n", word)
|
DEBUG("parse.fnddef: Looking up defined constant '%s'\n", word)
|
||||||
for (conidx=0; conidx<concnt; conidx++)
|
for (conidx=0; conidx<concnt; conidx++)
|
||||||
if (strcmp(connam[conidx], name) == 0) return;
|
if (strcmp(connam[conidx], name) == 0) return;
|
||||||
conidx = -1;
|
conidx = -1;
|
||||||
@ -347,7 +347,7 @@ void prslit(void) {
|
|||||||
strcpy(word, value); //Patch for DASM
|
strcpy(word, value); //Patch for DASM
|
||||||
strcpy(value, "#");
|
strcpy(value, "#");
|
||||||
strcat(value, word);
|
strcat(value, word);
|
||||||
DEBUG("Generated literal '%s'\n", value)
|
DEBUG("parse.prslit: Generated literal '%s'\n", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get Value Type */
|
/* Get Value Type */
|
||||||
@ -362,7 +362,7 @@ int gettyp(void) {
|
|||||||
void prsopr(void) {
|
void prsopr(void) {
|
||||||
if (!isoper()) expctd("Arithmetic or bitwise operator");
|
if (!isoper()) expctd("Arithmetic or bitwise operator");
|
||||||
oper = getnxt();
|
oper = getnxt();
|
||||||
DEBUG("Parsed operator '%c'\n", oper)
|
DEBUG("parse.prsopr: Parsed operator '%c'\n", oper)
|
||||||
CCMNT(oper);
|
CCMNT(oper);
|
||||||
skpspc();
|
skpspc();
|
||||||
}
|
}
|
||||||
@ -443,7 +443,7 @@ int prspst(char poper, char trmntr, int isint, char* name, char* index, char ind
|
|||||||
if (poper) oper = poper;
|
if (poper) oper = poper;
|
||||||
else oper = getnxt();
|
else oper = getnxt();
|
||||||
CCMNT(oper);
|
CCMNT(oper);
|
||||||
DEBUG("Checking for post operation '%c'\n", oper)
|
DEBUG("parse.prspst: Checking for post operation '%c'\n", oper)
|
||||||
if (nxtchr == oper) {
|
if (nxtchr == oper) {
|
||||||
skpchr();
|
skpchr();
|
||||||
CCMNT(oper);
|
CCMNT(oper);
|
||||||
@ -451,6 +451,6 @@ int prspst(char poper, char trmntr, int isint, char* name, char* index, char ind
|
|||||||
prcpst(isint, name, index, indtyp, ispntr); //Process Post-Op
|
prcpst(isint, name, index, indtyp, ispntr); //Process Post-Op
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DEBUG("Not a post operation\n", 0)
|
DEBUG("parse.prspst: Not a post operation\n", 0)
|
||||||
return oper;
|
return oper;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user