aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-09 02:13:28 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-09 02:13:28 -0400
commitcc70315865cf02618f70aaaa75d9688d35d0de85 (patch)
treee9072b88cad1a536128772e55b605c4fd38497ed
parent45f24807e644f9629395384d903ce9623f3fd9e0 (diff)
downloadbw-atari8-tools-cc70315865cf02618f70aaaa75d9688d35d0de85.tar.gz
whichbas: improve DEC/HEX$ logic.
-rw-r--r--whichbas.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/whichbas.c b/whichbas.c
index c040950..6d7fbf4 100644
--- a/whichbas.c
+++ b/whichbas.c
@@ -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...