aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-10 04:57:12 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-10 04:57:12 -0400
commite5849386d9d6c026e6ca9b7fb353b8e66688adc1 (patch)
tree380e7c040eb9a5f7eda5d2197e3aac532680d4e6
parent683420816b9e886d047f452ef52201251992ba1b (diff)
downloadbw-atari8-tools-e5849386d9d6c026e6ca9b7fb353b8e66688adc1.tar.gz
whichbas: detect string concatenation with comma (BXL/BXE, assignments only).
-rw-r--r--whichbas.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/whichbas.c b/whichbas.c
index 586fd0b..0aeb5d1 100644
--- a/whichbas.c
+++ b/whichbas.c
@@ -249,17 +249,27 @@ int is_string_func(unsigned char tok) {
/* return true if a token is:
- a string constant,
- a string variable,
- - a string expression operator, like OP_STR_LE,
- a function that returns a string.
*/
-int is_string_op(unsigned char tok) {
+int is_string_rval(unsigned char tok) {
return
is_string_const (tok) ||
is_string_func (tok) ||
- is_string_exp_op (tok) ||
is_string_var (tok) ;
}
+/* return true if a token is:
+ - a string constant,
+ - a string variable,
+ - a string expression operator, like OP_STR_LE,
+ - a function that returns a string.
+*/
+int is_string_op(unsigned char tok) {
+ return
+ is_string_rval (tok) ||
+ is_string_exp_op (tok) ;
+}
+
void remove_type(int type) {
bas_type &= ((~type) & 0x0f);
@@ -629,6 +639,18 @@ CALLBACK(handle_op) {
}
}
+ /* BXL/BXE allows string concatenation in assignment with the comma,
+ A$="FOO","BAR" or A$=C$,D$. */
+ if(last_cmd == CMD_LET || last_cmd == CMD_ILET) {
+ if(program[last_cmd_pos + 2] == OP_STR_ASSIGN) {
+ if(tok == OP_COMMA) {
+ if(is_string_rval(nexttok)) {
+ remove_type(BT_ATARI | BT_TURBO);
+ }
+ }
+ }
+ }
+
if(tok == OP_HEXCONST) remove_type(BT_ATARI); /* hex const (turbo *and* bxl/xe) */
if(tok <= OP_FUNC_STRIG) {
if(verbose) fprintf(stderr, " bas_type now %02x\n", bas_type);
@@ -715,27 +737,12 @@ CALLBACK(handle_op) {
break;
case 0x5c: /* DEC (function, takes str) in TB, HEX$ (function, takes num) in BXL/BXE */
- if(is_string_op(nexttok2)) {
+ /* COMPLETE */
+ if(is_string_rval(nexttok2)) {
remove_type(BT_BXL_BXE);
} else if(is_numeric_op(nexttok2)) {
remove_type(BT_TURBO);
}
-
- /* old implementation: */
- /* 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 == 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...