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