Compare commits

...

3 Commits

Author SHA1 Message Date
Curtis F Kaylor 8495b43011 Merge branch 'master' of https://github.com/RevCurtisP/C02 2022-01-13 20:12:03 -05:00
Curtis F Kaylor e16b4dbeae Added -I option to c02 compiler 2021-12-18 19:38:15 -05:00
Curtis F Kaylor e13bd5809c Added function names to DEBUG, cleaned prslit() calls 2021-12-18 19:37:31 -05:00
2 changed files with 14 additions and 3 deletions

View File

@ -140,7 +140,7 @@ int popt(int arg, int argc, char *argv[]) {
strncpy (argstr, argv[arg], 31);
if (strlen(argstr) != 2) ERROR("malformed option %s\n", argstr, EXIT_FAILURE)
opt = toupper(argstr[1]);
if (strchr("CHS", opt)) {
if (strchr("CHIS", opt)) {
if (++arg >= argc) ERROR("Option -%c requires an argument\n", opt, EXIT_FAILURE)
strncpy(optarg, argv[arg], 31);
}
@ -158,6 +158,11 @@ int popt(int arg, int argc, char *argv[]) {
strcpy(hdrnam, optarg);
DEBUG("c02.popt: Header Name set to '%s'\n", hdrnam)
break;
case 'I':
strcpy(incdir, optarg);
strcat(incdir, "/");
DEBUG("c02.popt: Include Directory set to '%s'\n", incdir)
break;
case 'S':
strcpy(subdir[subcnt], optarg);
DEBUG("c02.popt: subdir[%d] ", subcnt)

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);
}