X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=token.c;fp=token.c;h=08a491678590fb17b6615895055406ffd1a9aeea;hp=93d958f7c6ca948105354854e1347c1ceebf3711;hb=7d748dc6e2259984c9093c48d84ae1ed280632ad;hpb=5559ac02922836380db93969986836bb004c8b37 diff --git a/token.c b/token.c index 93d958f..08a4916 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,6 +154,7 @@ static char * regname[] = { "a10","b10","x","y","","","ab","ba" // 312,319 }; +WARNING("We should get rid of this table, it's a subset of the table above") static char * riscregname[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", @@ -509,14 +517,14 @@ arg_num: // This is a hack. It might be better table-driven. d = NULL; - if ((*tk >= KW_D0) && !rdsp && !rgpu) + if ((*tk >= REG68_D0) && !rdsp && !rgpu) { - d = regname[(int)*tk++ - KW_D0]; + d = regname[(int)*tk++ - REG68_D0]; goto strcopy; } - else if ((*tk >= KW_R0) && (*tk <= KW_R31)) + else if ((*tk >= REGRISC_R0) && (*tk <= REGRISC_R31)) { - d = riscregname[(int)*tk++ - KW_R0]; + d = riscregname[(int)*tk++ - REGRISC_R0]; goto strcopy; } else @@ -1156,14 +1164,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 +1180,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) { @@ -1530,14 +1549,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 +1564,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)