aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-06-18 06:09:10 -0400
committerB. Watson <urchlay@slackware.uk>2024-06-18 06:09:10 -0400
commit227133e626c6956f850e7d21c93f04882208ffed (patch)
tree883c1d561feea847f025ce79cceeba956b63ad19
parent9d6be822e814d38ec5eff0ddcc8bc936e7d1b6f2 (diff)
downloadbw-atari8-tools-227133e626c6956f850e7d21c93f04882208ffed.tar.gz
cxrefbas and renumbas: support LIST.
-rw-r--r--cxrefbas.114
-rw-r--r--cxrefbas.c15
-rw-r--r--cxrefbas.rst14
-rw-r--r--linetab.c21
4 files changed, 49 insertions, 15 deletions
diff --git a/cxrefbas.1 b/cxrefbas.1
index bc028ef..2850ac1 100644
--- a/cxrefbas.1
+++ b/cxrefbas.1
@@ -37,8 +37,14 @@ cxrefbas [\fB\-v\fP] \fBinput\-file\fP
.sp
\fBcxrefbas\fP reads an Atari 8\-bit BASIC tokenized program. For each
line number in the program, it prints a list of lines that reference
-it. Each line number reference is followed by a letter that indicates
-the type of reference:
+it.
+.sp
+\fBinput\-file\fP must be a tokenized (SAVEd) Atari BASIC program. Use
+\fI\-\fP to read from standard input, but \fBcxrefbas\fP will refuse to read
+from standard input if it\(aqs a terminal.
+.sp
+Each line number reference in the output is followed by a letter that
+indicates the type of reference:
.INDENT 0.0
.TP
.B \fBG\fP
@@ -58,6 +64,10 @@ the type of reference:
.TP
.B \fBT\fP
\fITRAP\fP\&.
+.TP
+.B \fBL\fP
+\fILIST\fP\&. It\(aqs very rare for a program to \fILIST\fP parts of itself, but
+it\(aqs allowed by BASIC so it\(aqs supported here.
.UNINDENT
.sp
If a line doesn\(aqt exist, but is referenced (e.g. \fIGOTO 100\fP, but there
diff --git a/cxrefbas.c b/cxrefbas.c
index ad7a640..690c0dd 100644
--- a/cxrefbas.c
+++ b/cxrefbas.c
@@ -19,14 +19,15 @@ void print_ref_table(void) {
for(j = 0; j < refcounts[i]; j++) {
printf("%d:", linerefs[i][j].lineno);
switch(linerefs[i][j].cmd) {
- case CMD_GOTO: c = 'G'; break;
- case CMD_GO_TO: c = 'G'; break;
- case CMD_GOSUB: c = 'S'; break;
+ case CMD_GOTO: c = 'G'; break;
+ case CMD_GO_TO: c = 'G'; break;
+ case CMD_GOSUB: c = 'S'; break;
case CMD_RESTORE: c = 'R'; break;
- case CMD_TRAP: c = 'T'; break;
- case CMD_IF: c = 'I'; break;
- case CMD_ON: c = 'O'; break;
- default: c = '?'; break;
+ case CMD_TRAP: c = 'T'; break;
+ case CMD_IF: c = 'I'; break;
+ case CMD_ON: c = 'O'; break;
+ case CMD_LIST: c = 'L'; break;
+ default: c = '?'; break;
}
putchar(c);
putchar(' ');
diff --git a/cxrefbas.rst b/cxrefbas.rst
index 3966e9c..d80d818 100644
--- a/cxrefbas.rst
+++ b/cxrefbas.rst
@@ -18,8 +18,14 @@ DESCRIPTION
**cxrefbas** reads an Atari 8-bit BASIC tokenized program. For each
line number in the program, it prints a list of lines that reference
-it. Each line number reference is followed by a letter that indicates
-the type of reference:
+it.
+
+**input-file** must be a tokenized (SAVEd) Atari BASIC program. Use
+*-* to read from standard input, but **cxrefbas** will refuse to read
+from standard input if it's a terminal.
+
+Each line number reference in the output is followed by a letter that
+indicates the type of reference:
**G**
*GOTO* (without *ON*) or *GO TO*.
@@ -39,6 +45,10 @@ the type of reference:
**T**
*TRAP*.
+**L**
+ *LIST*. It's very rare for a program to *LIST* parts of itself, but
+ it's allowed by BASIC so it's supported here.
+
If a line doesn't exist, but is referenced (e.g. *GOTO 100*, but there
is no line 100), it's printed in the table, prefixed with *!*.
diff --git a/linetab.c b/linetab.c
index 5fb0a32..669b1a0 100644
--- a/linetab.c
+++ b/linetab.c
@@ -75,16 +75,15 @@ void computed_msg(unsigned short lineno) {
cmd = "RESTORE"; break;
case CMD_TRAP:
cmd = "TRAP"; break;
- /*
- case CMD_IF:
- cmd = "IF/THEN"; break;
- */
case CMD_ON:
if(on_op == OP_GOSUB)
cmd = "ON/GOSUB";
else
cmd = "ON/GOTO";
break;
+ case CMD_LIST:
+ cmd = "LIST";
+ break;
default: /* should never happen! */
cmd = "???"; break;
}
@@ -99,6 +98,7 @@ CALLBACK(got_var) {
case CMD_GOSUB:
case CMD_RESTORE:
case CMD_TRAP:
+ case CMD_LIST:
computed_msg(lineno);
break;
default:
@@ -150,6 +150,19 @@ CALLBACK(got_exp) {
}
}
break;
+ case CMD_LIST: {
+ switch(last_tok) {
+ case CMD_LIST:
+ case OP_COMMA:
+ if(standalone)
+ add_lineref(lineno, pos + 1);
+ else
+ computed_msg(lineno);
+ break;
+ default:
+ break;
+ }
+ }
default:
break;
}