1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-22 01:31:33 +00:00

Added function names to DEBUG, cleaned prslit() calls

This commit is contained in:
Curtis F Kaylor 2021-12-18 19:28:47 -05:00
parent 0ad8115dab
commit e13bd5809c
42 changed files with 82 additions and 70 deletions

View File

@ -22,7 +22,7 @@ int cmpenc; //Encoded Comparator Character
* Returns: Comparison Operator Bit Mask */
int enccmp(char c) {
int e;
DEBUG("Encoding Comparison Character '%c'", c)
DEBUG("cond.enccm: Encoding Comparison Character '%c'", c)
switch(c) {
case '=': e = 1; break;
case '<': e = 2; break;
@ -39,7 +39,7 @@ int enccmp(char c) {
* Uses: term - Term Being Compared Against *
* label - Branch Target if Comparison is FALSE */
void prccmp(void) {
DEBUG("Processing comparator %d", cmprtr) DETAIL(" with REVCMP=%d\n", revcmp)
DEBUG("cond.prccmp: Processing comparator %d", cmprtr) DETAIL(" with REVCMP=%d\n", revcmp)
if (cmprtr > 7) { //Process Flag
cmprtr = (cmprtr ^ revcmp) & 1; //Apply Reversal
if (cmprtr) asmlin("BPL", cmplbl);
@ -81,12 +81,12 @@ void prscmp(int revrse) {
skpspc();
if (cmprtr) prstrm(FALSE, TRUE);
//prccmp(); - Do after check for logical operator
DEBUG("Parsed comparator %d\n", cmprtr)
DEBUG("cond.prscmp: Parsed comparator %d\n", cmprtr)
}
/* Parse Flag Operator */
void prsflg(int revrse) {
DEBUG("Parsing Flag Operator '%c'\n", nxtchr)
DEBUG("cond.prsflg: Parsing Flag Operator '%c'\n", nxtchr)
if (match('+')) cmprtr = 8; //Bit 0 = 0
else if (match('-')) cmprtr = 9; //Bit 1 = 1
else expctd("Flag operator");
@ -96,40 +96,40 @@ void prsflg(int revrse) {
/* Parse Logical Operator *
* Sets: logops */
void prslop(void) {
DEBUG("Checking for Logical Operator\n", 0)
DEBUG("cond.prslop: Checking for Logical Operator\n", 0)
logopr = LOPNONE;
skpspc();
if (isalph()) {
getwrd(); //Get Logical Operator
DEBUG("Parsing Logical Operator %s\n", word)
DEBUG("cond.prslop: Parsing Logical Operator %s\n", word)
if (wordis("AND")) logopr = LOPAND;
else if (wordis("OR")) logopr = LOPOR;
else ERROR("Encountered invalid token \"%s\"\n", word, EXIT_FAILURE)
}
DEBUG("Set LOGOPR to %d\n", logopr)
DEBUG("cond.prslop: Set LOGOPR to %d\n", logopr)
}
/* Parse and Compile Conditional Expression *
* Condition = <expression> <comparator> <term> */
void prscnd(char trmntr, int revrse) {
DEBUG("Parsing condition with REVRSE=%d\n", revrse)
DEBUG("cond.prscnd: Parsing condition with REVRSE=%d\n", revrse)
tmplbl[0] = 0;
do {
strcpy(cmplbl, cndlbl); DEBUG("Set CMPLBL to \"%s\"\n", cmplbl);
strcpy(cmplbl, cndlbl); DEBUG("cond.prscnd: Set CMPLBL to \"%s\"\n", cmplbl);
revcmp = revrse;
if (look('!')) revcmp = (revcmp) ? FALSE: TRUE;
DEBUG("Set REVCMP to %d\n", revcmp)
DEBUG("cond.prscnd: Set REVCMP to %d\n", revcmp)
if (!look('.')) prsxpr(0);
if (look(':')) prsflg(revcmp); //Parse Flag Operator
else prscmp(revcmp); //Parse Comparison Operator
prslop(); //Parse Logical Operator
if (logopr == LOPOR) {
revcmp = (revcmp) ? FALSE: TRUE;
DEBUG("Set REVCMP to %d\n", revcmp)
DEBUG("cond.prscnd: Set REVCMP to %d\n", revcmp)
}
if (logopr && revcmp) {
if (!tmplbl[0]) newlbl(tmplbl);
strcpy(cmplbl, tmplbl); DEBUG("Set CMPLBL to \"%s\"\n", cmplbl);
strcpy(cmplbl, tmplbl); DEBUG("cond.prscnd: Set CMPLBL to \"%s\"\n", cmplbl);
}
prccmp(); //Process Comparison/Flag Operator
} while (logopr);

View File

@ -51,7 +51,7 @@ void addfnc(void) {
expect(')');
if (look(';')) return; //Forward Definition
infunc = TRUE; //Set Inside Function Definition Flag
DEBUG("Set infunc to %d\n", infunc)
DEBUG("dclrtn.addfnc: Set infunc to %d\n", infunc)
setlbl(fncnam); //Set Function Entry Point
asmlin(LOCOP, ""); //Set Local Variables Boundary
if (prmtra[0]) asmlin("STA", prmtra); //Store First Parameter
@ -72,7 +72,7 @@ void addcon(int numval) {
if (alcvar) setlbl(defnam); //Set label Assembler Line
conval[concnt++] = numval; //Get Value
if (alcvar) asmlin(EQUOP, value); //Write Definition
DEBUG("Defined constant '%s'", defnam)
DEBUG("dclrtn.addcon: Defined constant '%s'", defnam)
DETAIL(" as '%s'\n", value)
if (!alcvar) SCMNT(""); //Clear Comment
}
@ -81,17 +81,17 @@ void addcon(int numval) {
*/
void penum(int m, int bitmsk) {
int enmval = (bitmsk) ? 1 : 0;
DEBUG("Processing Enum Declarations with BITMSK %d\n", bitmsk)
DEBUG("dclrtn.enum: Processing Enum Declarations with BITMSK %d\n", bitmsk)
if (m != MTNONE) ERROR("Illegal Modifier %d in Enum Definition", m, EXIT_FAILURE)
expect('{');
do {
if (enmval > 0xFF) ERROR("Maximum ENUM or BITMASK value exceeded\n", 0, EXIT_FAILURE)
if (look('.'))
DEBUG("Skipping sequence %d\n", enmval)
DEBUG("dclrtn.penum: Skipping sequence %d\n", enmval)
else {
getwrd(); //get defined identifier
DEBUG("Enumerating '%s'", word)
DEBUG(" as %d\n", enmval);
DEBUG("dclrtn.penum: Enumerating '%s'", word)
DEBUG("dclrtn.penum: as %d\n", enmval);
strncpy(defnam, word, VARLEN);
sprintf(value, "%d", enmval);
addcon(enmval);
@ -101,12 +101,12 @@ void penum(int m, int bitmsk) {
} while (look(','));
expect('}');
expect(';');
DEBUG("Enum Declaration Completed\n", 0)
DEBUG("dclrtn.penum: Enum Declaration Completed\n", 0)
}
/* Parse Enum Declaration*/
void pstrct(int m) {
DEBUG("Processing Struct Declarations\n", 0)
DEBUG("dclrtn.pstrct: Processing Struct Declarations\n", 0)
getwrd(); //Parse Structure Name
if (look('{')) defstc(); //Parse Struct Definition
else addstc(); //Parse and Compile Struct Declaration
@ -115,18 +115,18 @@ void pstrct(int m) {
/* Parse Variable/Function Declaration*/
void pdecl(int m, int t) {
DEBUG("Processing declaration(s) of type %d\n", t)
DEBUG("dclrtn.pdegl: Processing declaration(s) of type %d\n", t)
do {
getwrd();
if (match('(')) {
if (m > MTNONE) ERROR("Illegal Modifier %d in Function Definition\n", m, EXIT_FAILURE)
if (m > MTNONE) ERROR("dclrtn.pdegl: Illegal Modifier %d in Function Definition\n", m, EXIT_FAILURE)
addfnc(); //Add Function Call
return;
}
addvar(m, t);
} while (look(','));
expect(';');
DEBUG("Declaration completed\n", 0)
DEBUG("dclrtn.pdegl: Declaration completed\n", 0)
cmtlin(); //Write out declaration comment
}
@ -162,13 +162,13 @@ int ptype(int m) {
int pmtype(int m) {
getwrd();
if (m == MTALGN && wordis("CONST")) {m = m | MTCONST; getwrd();}
DEBUG("Parsing type %s\n", word)
DEBUG("dclrtn.pmtype: Parsing type %s\n", word)
return ptype(m);
}
/* Check for and Parse Modifier */
int pmodfr(void) {
DEBUG("Parsing modifier '%s'\n", word)
DEBUG("dclrtn.pmodfr: Parsing modifier '%s'\n", word)
int result = TRUE;
if (wordis("ALIAS")) { pmtype(MTALS); }
else if (wordis("ALIGNED")) { pmtype(MTALGN); }

View File

@ -29,7 +29,7 @@ void poptrm(void) {
trmidx--; //Decrement Stack Pointer
strcpy(term, trmstk[trmidx]); //Restore Current Term from Stack
oper = oprstk[trmidx]; //Restore Current Operator from Stack
DEBUG("expr.pshtrm: Popped term %s ", term)
DEBUG("expr.poptrm: Popped term %s ", term)
DETAIL("and operator '%c' off stack\n", oper)
}
@ -42,6 +42,7 @@ void prsval(int alwreg, int alwcon) {
DEBUG("expr.prsval: Parsing value\n", 0)
skpspc();
if (islpre()) prslit(); //Parse Literal
else if (islpre()) prslit(TRUE); //Parse Literal
else if (isalph()) prsvar(alwreg, alwcon); //Parse Variable
else if (isbtop()) prsbop(); //Parse Byte Operator
else expctd("literal or variable");
@ -308,6 +309,7 @@ void prsfnc(char trmntr) {
skpchr(); //skip open paren
CCMNT('(');
prsfpr(')'); //Parse Function Parameters
DEBUG("expr.prsfnc: Checking for terminator #%d\n", trmntr)
expect(trmntr);
poptrm(); //Pop Function Name off Term Stack
asmlin("JSR", term);
@ -326,6 +328,8 @@ void prcvri(void) {
* Args: alwint = Allow Integer-Like Variable *
* Returns: Integer-Like Variable Processed - TRUE/FALSE */
int prcivr(int alwint) {
DEBUG("expr.prcivr: Processing Integer Variiable %s", word)
DETAIL(" of type %d\n", vartyp)
switch (vartyp) {
case VTINT:
if (!alwint) ERROR("Illegal Use of Integer Variable %s\n", word, EXIT_FAILURE)
@ -432,7 +436,7 @@ void prsxpi(char trmntr, int asmxpr) {
DEBUG("expr.prsxpi: Parsing integer expression\n", 0)
if (!chkadr(TRUE, FALSE)) {
if (isnpre()) {
DEBUG("expr.prsxpi: 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);
@ -441,6 +445,7 @@ void prsxpi(char trmntr, int asmxpr) {
} else if (isalph()) {
prsvar(FALSE, TRUE);
if (valtyp == FUNCTION) {
DEBUG("stmnt.prrsxpi: Parsing function %s\n", value)
strcpy(term, value);
DEBUG("expr.prsxpi: Set term to %s\n", term)
prsfnc(0); //Parse Expression Function
@ -456,5 +461,6 @@ void prsxpi(char trmntr, int asmxpr) {
ERROR("Expected Integer Value or Function\n", 0, EXIT_FAILURE);
}
}
DEBUG("expr.prsxpi: Checking for terminater #%d\n", trmntr)
expect(trmntr);
}

View File

@ -22,9 +22,9 @@ void extsys(char *s) {
* Uses: srcnam - Source File Name *
* Sets: srcfil - Source File Handle */
void opnsrc(void) {
DEBUG("Processing Source File Name '%s'\n", srcnam)
DEBUG("files.opnsrc: Processing Source File Name '%s'\n", srcnam)
if (strrchr(srcnam, '.') == NULL) strcat(srcnam, ".c02"); //if no extension. add ".c02"
DEBUG("opening Source File '%s'\n", srcnam)
DEBUG("files.opnsrc: Opening Source File '%s'\n", srcnam)
srcfil = fopen(srcnam, "r"); //open file
if (srcfil == NULL) extsys(srcnam);
}
@ -36,16 +36,16 @@ void clssrc(void) { fclose(srcfil); }
* Uses: outnam - Output File Name *
* Sets: outfil - Output File Handle */
void opnout(void) {
DEBUG("Processing Output File Name '%s'\n", outnam)
DEBUG("files.opnout: Processing Output File Name '%s'\n", outnam)
if (strlen(outnam) == 0) //if Output File not specified
{
strcpy(outnam, srcnam); //copy Source Name to Ouput Name
char *dot = strrchr(outnam, '.'); //find extension
if (dot != NULL) *dot = 0; //and remove it
DEBUG("Set Output File Name to '%s'\n", outnam)
DEBUG("files.opnout: Set Output File Name to '%s'\n", outnam)
}
if (strrchr(outnam, '.') == NULL) strcat(outnam, ".asm"); //if no extension, add ".asm"
DEBUG("Opening Output File '%s'\n", outnam)
DEBUG("files.opnout: Opening Output File '%s'\n", outnam)
outfil = fopen(outnam, "w"); //open file
if (outfil == NULL) extsys(outnam);
}
@ -64,7 +64,7 @@ void opnlog(void) {
char *dot = strrchr(lognam, '.'); //find file extension
if (dot != NULL) *dot = 0; //and remove it
strcat(lognam, ".log"); //add extension ".log"
DEBUG("Opening Log File '%s'\n", lognam)
DEBUG("files.opnlog: Opening Log File '%s'\n", lognam)
logfil = fopen(lognam, "w");
if (logfil == NULL) extsys(lognam);
}
@ -81,18 +81,18 @@ void opninc(int chksub)
{
if (chksub) {
for (subidx=0; subidx<subcnt; subidx++) {
DEBUG("Attempting to open include file '%s'\n", subnam[subidx])
DEBUG("files.opninc: Attempting to open include file '%s'\n", subnam[subidx])
incfil = fopen(subnam[subidx], "r");
if (incfil == NULL) DEBUG("Open failed\n", 0)
if (incfil == NULL) DEBUG("files.opninc: Open failed\n", 0)
else {
strcpy(incnam, subnam[subidx]);
DEBUG("INCNAM set to '%s'\n", incnam);
DEBUG("files.opninc: INCNAM set to '%s'\n", incnam);
return;
}
}
}
DEBUG("Opening include file '%s'\n", incnam)
DEBUG("files.opninc: Opening include file '%s'\n", incnam)
incfil = fopen(incnam, "r");
if (incfil == NULL) extsys(incnam);
}

View File

@ -21,7 +21,7 @@
/* Read next include file name from Source File *
* Sets: incnam - the include file name */
void pincnm(void) {
DEBUG("Parsing include file name", 0)
DEBUG("include.pincnm: Parsing include file name", 0)
char dlmtr;
int inclen = 0;
int sublen[SUBMAX];
@ -54,11 +54,11 @@ void pincnm(void) {
}
skpchr(); //skip end dlmtr
incnam[inclen] = 0;
DEBUG("Set INCNAM to '%s'\n", incnam);
DEBUG("include.pincnm: Set INCNAM to '%s'\n", incnam);
for (int subidx = 0; subidx < subcnt; subidx++) {
subnam[subidx][sublen[subidx]] = 0;
DEBUG("Set SUBNAM[%d] ", subidx)
DEBUG("to '%s'\n", subnam[subidx]);
DEBUG("include.pincnm: Set SUBNAM[%d] ", subidx)
DETAIL("to '%s'\n", subnam[subidx]);
}
}
@ -70,7 +70,7 @@ void incasm(int chksub) {
addcmt(" =======");
cmtlin();
while (fgets(line, sizeof line, incfil) != NULL) {
DEBUG("Writing line: %s", line)
DEBUG("include.incasm: Writing line: %s", line)
fputs(line, outfil);
}
setcmt("==========================================");
@ -80,7 +80,7 @@ void incasm(int chksub) {
/* Process define directive */
void pdefin(void) {
DEBUG("Processing DEFINE directive\n", 0)
DEBUG("include.pdefin: Processing DEFINE directive\n", 0)
getwrd(); //Get constant name
strncpy(defnam, word, CONLEN);
addcon(prsbyt()); //Get Value and Add Constant
@ -89,7 +89,7 @@ void pdefin(void) {
/* Parse ASCII Subdirective */
void pascii(void) {
getwrd(); //Get Subdirective Argument
DEBUG("Parsing subdirective '%s'\n", word)
DEBUG("include.pascii: Parsing subdirective '%s'\n", word)
if (wordis("INVERT"))
invasc = TRUE;
else if (wordis("HIGH"))
@ -102,26 +102,26 @@ void pascii(void) {
void porign(void) {
prsnum(0xFFFF); //Get Origin Address
asmlin(ORGOP, value); //Emit Origin Instruction
DEBUG("Set origin to %s\n", value)
DEBUG("include.poirgn: Set origin to %s\n", value)
}
/* Parse Padding Subdirective */
void ppddng(void) {
padcnt = prsnum(0xFF); //Get Number of Padding Bytes
DEBUG("Set padding to %d\n", padcnt)
DEBUG("include.ppddng: Set padding to %d\n", padcnt)
}
/* Parse RamBase Subdirective */
void prambs(void) {
rambas = prsnum(0xFFFF); //Set Ram Base Address to Literal
DEBUG("Set ram base address to %d\n", rambas)
DEBUG("include.prambs: Set ram base address to %d\n", rambas)
}
/* Parse WriteBase Subdirective */
void pwrtbs(void) {
if (!rambas) ERROR("RAM Base must be set prior to Write Base\n", 0, EXIT_FAILURE);
wrtbas = prsnum(0xFFFF); //Set Ram Base Address to Literal
DEBUG("Set write base address to %d ", wrtbas)
DEBUG("include.pwrtbs: Set write base address to %d ", wrtbas)
if (rambas && wrtbas) sprintf(wrtofs, "%+d", wrtbas - rambas);
else wrtofs[0] = 0;
DETAIL("and write offset to '%s'\n", wrtofs)
@ -132,7 +132,7 @@ void pzropg(void) {
zpgbgn = prsnum(0xFF); //Set Zero Page Address to Literal
zpgend = prsnum(0xFF); //Set Zero Page Address to Literal
zpaddr = zpgbgn;
DEBUG("Set free zero page to %d ", zpgbgn)
DEBUG("include.pzropg: Set free zero page to %d ", zpgbgn)
DETAIL("through %d ", zpgend)
DETAIL("and zero page address to %d\n", zpaddr)
}
@ -146,7 +146,7 @@ void pvrtbl(void) {
/* Parse Pragma Directive */
void pprgma(void) {
getwrd(); //Get Pragma Subdirective
DEBUG("Parsing pragma directive '%s'\n", word)
DEBUG("include.pprgma: Parsing pragma directive '%s'\n", word)
if (wordis("ASCII"))
pascii(); //Parse Ascii
else if (wordis("ORIGIN"))
@ -170,7 +170,7 @@ void pprgma(void) {
void pincdr(void) {
skpchr(); //skip '#'
getwrd(); //read directive into word
DEBUG("Processing include file directive '%s'\n", word)
DEBUG("include.pincdr: Processing include file directive '%s'\n", word)
if (wordis("DEFINE"))
pdefin();
else if (wordis("PRAGMA"))
@ -236,7 +236,7 @@ void inchdr(int chksub) {
{
skpspc();
if (match(EOF)) break;
DEBUG("Checking next character '%c'\n", nxtchr)
DEBUG("include.inchdr: Checking next character '%c'\n", nxtchr)
if (match('#'))
pincdr();
else if (match('/'))
@ -255,7 +255,7 @@ void inchdr(int chksub) {
/* Process Header File specified on Command Line */
void phdrfl(void) {
if (hdrnam[0] == 0) return;
DEBUG("Processing Header '%s'\n", hdrnam)
DEBUG("include.phdrfl: Processing Header '%s'\n", hdrnam)
setinm(".h02");
inchdr(TRUE);
setinm(".a02");
@ -265,7 +265,7 @@ void phdrfl(void) {
/* Process include file */
void pincfl(void) {
pincnm(); //Parse Include File Name
DEBUG("Processing include file '%s'\n", incnam)
DEBUG("include.pincfl: Processing include file '%s'\n", incnam)
char *dot = strrchr(incnam, '.'); //find extension
if (dot == NULL) {
ERROR("Invalid include file name '%sn", incnam, EXIT_FAILURE)
@ -278,7 +278,7 @@ void pincfl(void) {
inchdr(TRUE); //Process Header File
dot = strrchr(incnam, '.'); //find extension
strcpy(dot, ".a02");
DEBUG("INCNAM set to '%s'\n", incnam)
DEBUG("include.pincfl: INCNAM set to '%s'\n", incnam)
incasm(FALSE); //Process Assembly File with Same Name
}
else {

View File

@ -294,8 +294,9 @@ void pdowhl(void) {
/* parse and compile for statement */
void pfor(void) {
DEBUG("stmnt.pfor: Parsing FOR statement '%c'\n", nxtchr);
DEBUG("stmnt.pfor: Parsing FOR statement'\n", 0);
expect('(');
DEBUG("stmnt.pfor: Parsing Initial Assignment\n", 0);
prsasn(';'); //Process Initial Assignment
newlbl(forlbl); //Create For Loop Conditional Label
setlbl(forlbl); //and Set to Emit on Next Line
@ -304,9 +305,11 @@ void pfor(void) {
newlbl(loplbl); //Create Loop Label
pshlbl(LTLOOP, loplbl); //and Push onto Stack
newlbl(cndlbl); //Create Conditional Label
DEBUG("stmnt.pfor: Parsing Loop Conditional\n", 0);
prscnd(';', TRUE); //Parse Conditional Expession
asmlin("JMP", endlbl); //Jump over Increment
setlbl(loplbl); //Set to Emit on Next Line
DEBUG("stmnt.pfor: Parsing Increment Assignment\n", 0);
prsasn(')'); //Parse Increment Assignment
asmlin("JMP", forlbl); //Jump to Conditional
setlbl(cndlbl); //Emit Label at Start of Loop
@ -383,7 +386,7 @@ void pinlne(void) {
asmlin(BYTEOP, value);
}
else {
prslit(0xFF); //Parse Literal
prslit(); //Parse Literal
sprintf(word, "$%hhX", litval); //not needed?
asmlin(BYTEOP, value);
}

View File

@ -20,4 +20,5 @@ void endblk(int blkflg); //End Program Block
void prcasp(char trmntr); //Process Pointer Assignment
void prcidx(int idxtyp, char *name, char *index);
void pdowhl(); //Parse and Compile WHILE after DO
void prssym(); //Parse and Compile Assignment or Function Call
void pstmnt(); //Parse and Compile Program Statement

View File

@ -144,7 +144,7 @@ void reqvar(int alwary) {
* Returns: variable size (as integer */
int pidxof(void) {
expect('?'); //Check for and Skip SizeOf Operator
DEBUG("vars.pidxof: Parsing IndexOf operator", 0);
DEBUG("vars.pidxof: Parsing IndexOf operator\n", 0);
mbridx = -1; //Set Member Index to None
reqvar(FALSE); //Parse Variable Name to get Size Of
if (mbridx > -1) {
@ -160,7 +160,7 @@ int pidxof(void) {
* Returns: variable size (as integer */
int psizof(void) {
expect('@'); //Check for and Skip SizeOf Operator
DEBUG("vars.pdizof: Parsing SizeOf operator", 0);
DEBUG("vars.psizof: Parsing SizeOf operator\n", 0);
mbridx = -1; //Set Member Index to None
reqvar(FALSE); //Parse Variable Name to get Size Of
if (mbridx > -1) {
@ -310,7 +310,8 @@ void addvar(int m, int t) {
skpchr();
if (alcvar) {
DEBUG("vars.addvar: Parsing array size\n", 0)
sprintf(value, "%d", prsnum(0xFF) + 1);
prslit();
sprintf(value, "%d", litval + 1);
}
expect(']');
}
@ -400,12 +401,12 @@ void addstc(void) {
/* Parse Struct Definition *
* Uses: word - Struct Name */
void defstc(void) {
DEBUG("Parsing struct definition\n", 0)
DEBUG("vars.defstc: Parsing struct definition\n", 0)
if (fndstc(word)) ERROR("Duplicate Declaration of Struct '%s\n", word,EXIT_FAILURE)
int type;
int prnidx = stcidx;
strncpy(strct.name, word, STCLEN);
DEBUG("Set struct name to '%s'\n", word);
DEBUG("vars.defstc: Set struct name to '%s'\n", word);
strct.size = 0; //Initialize Struct Length
while (look('/')) skpcmt(FALSE); //Skip Comments
do {
@ -434,10 +435,10 @@ void defstc(void) {
default:
ERROR("Invalid Type %s in Struct Definition\n", word, EXIT_FAILURE)
}
DEBUG("Parsing members of type %s\n", word)
DEBUG("vars.defstc: Parsing members of type %s\n", word)
do {
getwrd(); //Get Member Name
DEBUG("Parsing member %s\n", word)
DEBUG("vars.defstc: Parsing member %s\n", word)
if (fndmbr(stccnt, word)) ERROR("Duplicate Declaration of Struct Member '%s\n", word,EXIT_FAILURE)
if (strlen(word) > STMLEN) ERROR("Member Name %s too long\n", word, EXIT_FAILURE)
strcpy(membr.name, word); //Set Member Name
@ -447,18 +448,19 @@ void defstc(void) {
membr.offset = strct.size; //Set Offset into Struct
membr.size = mbrsiz; //Set Member Size
if (membr.vartyp == VTCHAR) {
DEBUG("Checking member for array definition\n", 0)
DEBUG("vars.defstc: Checking member for array definition\n", 0)
if (match('[')) {
CCMNT('[');
skpchr();
membr.vartyp = VTARRAY;
DEBUG("Parsing member array size\n", 0)
membr.size = prsnum(0xFF) + 1;
DEBUG("vars.defstc: Parsing member array size\n", 0)
prslit();
membr.size = litval + 1;
expect(']');
}
}
DEBUG("Set member type to %d", membr.vartyp) DETAIL(" and size to %d\n", membr.size);
DEBUG("Adding member at index %d\n", mbrcnt);
DEBUG("vars.defstc: Set member type to %d", membr.vartyp) DETAIL(" and size to %d\n", membr.size);
DEBUG("vars.defstc: Adding member at index %d\n", mbrcnt);
membrs[mbrcnt++] = membr;
strct.size += membr.size;
} while (look(','));
@ -467,7 +469,7 @@ void defstc(void) {
} while (!look('}'));
expect(';');
if (strct.size > 256) ERROR("Structure Size %d Exceeds Limit of 256 bytes.\n", strct.size, EXIT_FAILURE);
DEBUG("Adding struct with size %d", strct.size) DETAIL("at index %d\n", stccnt);
DEBUG("vars.defstc: Adding struct with size %d", strct.size) DETAIL("at index %d\n", stccnt);
strcts[stccnt++] = strct;
}