aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--whichbas.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/whichbas.c b/whichbas.c
index 54a4f03..2b84285 100644
--- a/whichbas.c
+++ b/whichbas.c
@@ -284,6 +284,21 @@ int is_string_op(unsigned char tok) {
is_string_exp_op (tok) ;
}
+/* true if an operator token is a string function in BASIC XL (or XE).
+ these tokens are all numeric functions in Turbo, so be sure you
+ know what you're doing! */
+int is_bxl_string_func(unsigned char tok) {
+ switch(tok) {
+ case 0x5c: /* BXL HEX$, Turbo DEC */
+ case 0x66: /* BXL LEFT$, Turbo %0 */
+ case 0x67: /* BXL RIGHT$, Turbo %1 */
+ case 0x68: /* BXL MID$, Turbo %2 */
+ return 1;
+ default:
+ return 0;
+ }
+}
+
void remove_type(int type) {
bas_type &= ((~type) & 0x0f);
@@ -800,20 +815,14 @@ CALLBACK(handle_op) {
case 0x66: /* %0 in TB, LEFT$( (pseudo-func, takes string) in BXL/BXE */
case 0x67: /* %1 in TB, RIGHT$( (pseudo-func, takes string) in BXL/BXE */
case 0x68: /* %2 in TB, MID$( (pseudo-func, takes string) in BXL/BXE */
- /* PARTIAL: doesn't handle LEFT$/etc first arg being a string func. */
- if(nexttok == OP_STRCONST || nexttok >= 0x80) {
- /* %0 %1 %2 can't be followed by a string constant *or* a variable */
+ /* COMPLETE */
+ /* LEFT$/RIGHT$/MID$ do NOT get OP_FUNC_LPAR (the "(" is part of the
+ token name). They're always followed by a string operator... and
+ it works out that none of the tokens for BXL-only string funcs
+ are allowed to follow %0 %1 %2 in Turbo. */
+ if(is_string_op(nexttok) || is_bxl_string_func(nexttok)) {
remove_type(BT_TURBO);
- /* Can't do, due to LEFT$(HEX$("1234"), 1) (or STR$, etc): */
- /* } else {
- remove_type(BT_BXL_BXE); */
- /* ...but this stuff helps: */
- } else if(nexttok == OP_EOS || nexttok == OP_EOL) {
- /* LEFT$ RIGHT$( MID$( can't occur at the end of a statement. */
- remove_type(BT_BXL_BXE);
- } else if(pos == (last_cmd_pos + 2) && program[pos - 1] == OP_NUM_ASSIGN) {
- /* LEFT$ RIGHT$( MID$( return strings, assignment would
- be OP_STR_ASSIGN. */
+ } else {
remove_type(BT_BXL_BXE);
}
break;