diff options
author | B. Watson <urchlay@slackware.uk> | 2024-06-18 06:53:54 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-06-18 06:53:54 -0400 |
commit | d79dd55a18cb158778fbdc796a60f27518d1f971 (patch) | |
tree | a8cd9509ad175161d228586543603ac8a90c4bc4 /linetab.c | |
parent | 0ac7d03ab5196ab2c1fbfa18dcc9ffeccef1a25e (diff) | |
download | bw-atari8-tools-d79dd55a18cb158778fbdc796a60f27518d1f971.tar.gz |
cxrefbas and renumbas: round fractional line numbers like BASIC does.
Diffstat (limited to 'linetab.c')
-rw-r--r-- | linetab.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -93,6 +93,8 @@ void computed_msg(unsigned short lineno) { CALLBACK(got_var) { switch(last_cmd) { + /* any use of a variable in the arguments to these means + we can't renumber that argument. */ case CMD_GOTO: case CMD_GO_TO: case CMD_GOSUB: @@ -102,6 +104,7 @@ CALLBACK(got_var) { computed_msg(lineno); break; case CMD_ON: + /* vars are OK in ON, before the GOTO or GOSUB */ if(on_op) computed_msg(lineno); break; default: @@ -119,9 +122,14 @@ CALLBACK(got_exp) { } if(tok != OP_NUMCONST) return; + + /* beware: standalone only means nothing *follows* the constant + in the same expression. still have to check last_tok to see + what came before. */ standalone = is_standalone_num(pos); switch(last_cmd) { + /* these take a single argument */ case CMD_GOTO: case CMD_GO_TO: case CMD_GOSUB: @@ -134,11 +142,14 @@ CALLBACK(got_exp) { } break; case CMD_IF: + /* this only applies to bare line numbers, like IF A THEN 1000, + not IF A THEN GOTO 1000 (or anything else after THEN). */ if(last_tok == OP_THEN) { add_lineref(lineno, pos + 1); } break; case CMD_ON: { + /* takes arbitrary number of arguments */ switch(last_tok) { case OP_GOTO: case OP_GOSUB: @@ -154,6 +165,7 @@ CALLBACK(got_exp) { } break; case CMD_LIST: { + /* takes one or two arguments */ switch(last_tok) { case CMD_LIST: case OP_COMMA: |