aboutsummaryrefslogtreecommitdiff
path: root/linetab.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-06-18 06:53:54 -0400
committerB. Watson <urchlay@slackware.uk>2024-06-18 06:53:54 -0400
commitd79dd55a18cb158778fbdc796a60f27518d1f971 (patch)
treea8cd9509ad175161d228586543603ac8a90c4bc4 /linetab.c
parent0ac7d03ab5196ab2c1fbfa18dcc9ffeccef1a25e (diff)
downloadbw-atari8-tools-d79dd55a18cb158778fbdc796a60f27518d1f971.tar.gz
cxrefbas and renumbas: round fractional line numbers like BASIC does.
Diffstat (limited to 'linetab.c')
-rw-r--r--linetab.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/linetab.c b/linetab.c
index 0351f59..59a96e3 100644
--- a/linetab.c
+++ b/linetab.c
@@ -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: