diff options
author | B. Watson <urchlay@slackware.uk> | 2024-07-09 02:13:28 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-07-09 02:13:28 -0400 |
commit | cc70315865cf02618f70aaaa75d9688d35d0de85 (patch) | |
tree | e9072b88cad1a536128772e55b605c4fd38497ed | |
parent | 45f24807e644f9629395384d903ce9623f3fd9e0 (diff) | |
download | bw-atari8-tools-cc70315865cf02618f70aaaa75d9688d35d0de85.tar.gz |
whichbas: improve DEC/HEX$ logic.
-rw-r--r-- | whichbas.c | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -495,21 +495,27 @@ CALLBACK(handle_op) { break; case 0x5a: /* EXOR (infix num op) or BUMP( (pseudo-function, no OP_FUNC_LPAR) */ case 0x5d: /* DIV (infix num op) or RANDOM( (pseudo-func, 1 or 2 num args) */ - if(last_op_tok == OP_NUMCONST || last_op_tok == OP_HEXCONST || last_op_tok >= 0x80) { - /* if the last token was a variable or a numeric, this is infix - (can't be a function, last token would have to have been a command - or a regular operator). */ + if(last_op_tok == OP_GRP_RPAR || last_op_tok == OP_NUMCONST || last_op_tok == OP_HEXCONST || last_op_tok >= 0x80) { + /* if the last token was a variable or a numeric, or a right paren, + this is infix (can't be a function, last token would have to have + been a command or a math/etc operator). */ remove_type(BT_BXL_BXE); } else { remove_type(BT_TURBO); } break; case 0x5c: /* DEC (function, takes str) in TB, HEX$ (function, takes num) in BXL/BXE */ + /* partial: won't catch HEX$(ASC("A")) (or any other nested function call) */ if(nexttok2 == OP_STRCONST) { remove_type(BT_BXL_BXE); - } else if(nexttok2 >= 0x80 && (get_vartype(nexttok2) == TYPE_STRING)) { - /* TODO: see if this test is actually valid! */ - remove_type(BT_BXL_BXE); + } else if(nexttok2 == OP_NUMCONST) { + remove_type(BT_TURBO); + } else if(nexttok2 >= 0x80) { + if(get_vartype(nexttok2) == TYPE_STRING) { + remove_type(BT_BXL_BXE); + } else { + remove_type(BT_TURBO); + } } break; case 0x5e: /* FRAC (num func, 1 arg) or DPEEK (num func, 1 arg) in BXL... |