From 5cd98cb8cd4d2835d7815e5c3604d6b0e9bf6eab Mon Sep 17 00:00:00 2001 From: ggn Date: Fri, 8 May 2020 20:20:40 +0300 Subject: [PATCH] Partial fix for bug #159. Some cases like .x still fail --- token.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/token.c b/token.c index 55dbc29..5047ed5 100644 --- a/token.c +++ b/token.c @@ -957,6 +957,7 @@ int TokenizeLine(void) int stuffnull; // 1:terminate SYMBOL '\0' at *nullspot uint8_t c1; int stringNum = 0; // Pointer to string locations in tokenized line + int is_first_symbol; // Flag for whether we're parsing the first symbol of the current line or not retry: @@ -980,7 +981,7 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); } goto retry; // Try for more lines else { - ifent->if_prev = (IFENT *)-1; //Signal Assemble() that we have reached EOF with unbalanced if/endifs + ifent->if_prev = (IFENT *)-1; // Signal Assemble() that we have reached EOF with unbalanced if/endifs return TKEOF; } } @@ -1073,6 +1074,8 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); } // o handle symbols; // o handle single-character tokens (operators, etc.); // o handle multiple-character tokens (constants, strings, etc.). + + is_first_symbol = 1; for(; *ln!=EOS;) { // Skip whitespace, handle EOL @@ -1105,13 +1108,14 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); } // start of a local symbol: if ((chrtab[*(ln + 1)] & DOT) && (dotxtab[*(ln + 1)] != 0) - && !(chrtab[*(ln + 2)] & CTSYM)) + && !(chrtab[*(ln + 2)] & CTSYM) && !is_first_symbol) { // We found a legitimate DOTx construct, so add it to the // token stream: ln++; stuffnull = 0; *tk.u32++ = (TOKEN)dotxtab[*ln++]; + is_first_symbol = 0; // We're certainly past that now continue; } } @@ -1144,8 +1148,10 @@ 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) + // a register. Do not run this on the first symbol of the line parsed + // as it may well alias with some of the register names (for example + // 'x' and 'y' are 6502 and 56001 registers + if (j <= KWSIZE && !is_first_symbol) { for(state=0; state>=0;) { @@ -1171,6 +1177,7 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); } { j = -1; } + is_first_symbol = 0; // 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)) -- 2.25.0.windows.1