blob: 8a7f8c1157a5611d65132c5204dd8a5823c8139b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include "bas.h"
#include "bcdfp.h"
#include "linetab.h"
void print_ref_table(void) {
char c;
int i, j;
for(i = 0; i < 32768; i++) {
if(refcounts[i]) {
if(!lines_exist[i]) putchar('!');
printf("%d: ", i);
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_RESTORE: c = 'R'; 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(' ');
}
putchar('\n');
}
}
}
void print_help(void) {
printf("Usage: %s [-v] program.bas\n", self);
exit(0);
}
void parse_args(int argc, char **argv) {
int opt;
while( (opt = getopt(argc, argv, "v")) != -1) {
switch(opt) {
case 'v': verbose = 1; break;
default: print_help(); exit(1);
}
}
if(optind >= argc)
die("No input file given (use - for stdin).");
else
open_input(argv[optind]);
}
int main(int argc, char **argv) {
set_self(*argv);
parse_general_args(argc, argv, print_help);
parse_args(argc, argv);
readfile();
parse_header();
build_ref_table();
print_ref_table();
free_ref_table();
return 0;
}
|