X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=token.c;h=55dbc290980722d06ed144755e43bb85587965a5;hp=93d958f7c6ca948105354854e1347c1ceebf3711;hb=HEAD;hpb=7a571a6d9ea7c7bf63cfbb4634f875d71653f872 diff --git a/token.c b/token.c index 93d958f..9cbf8b4 100644 --- a/token.c +++ b/token.c @@ -19,6 +19,13 @@ #define DECL_KW // Declare keyword arrays #define DEF_KW // Declare keyword values #include "kwtab.h" // Incl generated keyword tables & defs +#define DEF_REG68 // Incl 68k register definitions +#include "68kregs.h" +#define DEF_REGRISC // Include GPU/DSP register definitions +#include "riscregs.h" +#define DEF_UNARY // Declare unary values +#define DECL_UNARY // Incl uanry keyword state machine tables +#include "unarytab.h" // Incl generated unary tables & defs int lnsave; // 1; strcpy() text of current line @@ -147,13 +154,6 @@ static char * regname[] = { "a10","b10","x","y","","","ab","ba" // 312,319 }; -static char * riscregname[] = { - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", - "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", - "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31" -}; - // // Initialize tokenizer @@ -509,14 +509,9 @@ arg_num: // This is a hack. It might be better table-driven. d = NULL; - if ((*tk >= KW_D0) && !rdsp && !rgpu) - { - d = regname[(int)*tk++ - KW_D0]; - goto strcopy; - } - else if ((*tk >= KW_R0) && (*tk <= KW_R31)) + if (*tk >= REG68_D0) { - d = riscregname[(int)*tk++ - KW_R0]; + d = regname[(int)*tk++ - REG68_D0]; goto strcopy; } else @@ -1156,14 +1151,15 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); } // If the symbol is small, check to see if it's really the name of // a register. - if (j <= KWSIZE) + uint8_t *p2 = p; + if (j <= 5) { - for(state=0; state>=0;) + for (state = 0; state >= 0;) { j = (int)tolowertab[*p++]; - j += kwbase[state]; + j += regbase[state]; - if (kwcheck[j] != state) + if (regcheck[j] != state) { j = -1; break; @@ -1171,38 +1167,48 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); } if (*p == EOS || p == ln) { - j = kwaccept[j]; + j = regaccept[j]; + goto skip_keyword; break; } - state = kwtab[j]; + state = regtab[j]; } } - else - { - j = -1; - } - // Make j = -1 if user tries to use a RISC register while in 68K mode - if (!(rgpu || rdsp || dsp56001) && ((TOKEN)j >= KW_R0 && (TOKEN)j <= KW_R31)) + // Scan for keywords + if ((j <= 0 || state <= 0) || p==p2) { - j = -1; + if (j <= KWSIZE) + { + for (state = 0; state >= 0;) + { + j = (int)tolowertab[*p2++]; + j += kwbase[state]; + + if (kwcheck[j] != state) + { + j = -1; + break; + } + + if (*p == EOS || p2 == ln) + { + j = kwaccept[j]; + break; + } + + state = kwtab[j]; + } + } + else + { + j = -1; + } } - // Make j = -1 if time, date etc with no preceeding ^^ - // defined, referenced, streq, macdef, date and time - switch ((TOKEN)j) - { - case 112: // defined - case 113: // referenced - case 118: // streq - case 119: // macdef - case 120: // time - case 121: // date - case KW_FILESIZE: // filesize - j = -1; - } - + skip_keyword: + // If we detected equrundef/regundef set relevant flag if (j == KW_EQURUNDEF) { @@ -1251,6 +1257,14 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); } if (stuffnull) // Arrange for string termination on next pass nullspot = ln; + if (disabled) + { + // When we are in a disabled code block, the only thing that can break out + // of this is an ".endif" keyword, so this is the minimum we have to parse + // in order to discover such a keyword. + goto goteol; + } + continue; } @@ -1530,14 +1544,14 @@ dostring: for(state=0; state>=0;) { // Get char, convert to lowercase - j = *p++; + j = (int)tolowertab[*p++]; - if (j >= 'A' && j <= 'Z') - j += 0x20; + //if (j >= 'A' && j <= 'Z') + // j += 0x20; - j += kwbase[state]; + j += unarybase[state]; - if (kwcheck[j] != state) + if (unarycheck[j] != state) { j = -1; break; @@ -1545,11 +1559,11 @@ dostring: if (*p == EOS || p == ln) { - j = kwaccept[j]; + j = unaryaccept[j]; break; } - state = kwtab[j]; + state = unarytab[j]; } if (j < 0 || state < 0)