aboutsummaryrefslogtreecommitdiff
path: root/bas2aplus.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-21 16:44:51 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-21 16:44:51 -0400
commit5a5a7137e84127b98391691ecab91dac1f666e81 (patch)
tree0fca62a938361dc510e6edd44ad63c0e363c11bf /bas2aplus.c
parent57fe23c251492b61558483cbde470700cc4083e7 (diff)
downloadbw-atari8-tools-5a5a7137e84127b98391691ecab91dac1f666e81.tar.gz
bas2aplus: error exit and message on bad tokens; tweak doc.
Diffstat (limited to 'bas2aplus.c')
-rw-r--r--bas2aplus.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/bas2aplus.c b/bas2aplus.c
index ee71130..de259aa 100644
--- a/bas2aplus.c
+++ b/bas2aplus.c
@@ -14,6 +14,8 @@
#include "bxl_tokens.c"
#include "bxe_tokens.c"
+int errs = 0;
+
/* there are a few more BXL commands past 0x55, but they have no
A+ equivalents. */
#define LAST_BXL_CMD 0x55
@@ -197,8 +199,9 @@ const char *get_tok_name(unsigned char tok, int is_cmd) {
}
void unsupported_msg(unsigned char tok, int lineno, int is_cmd) {
- fprintf(stderr, "%s: Invalid %s \"%s\" (%02x) at line %d, not converted.\n",
+ fprintf(stderr, "%s: Invalid %s \"%s\" ($%02x) at line %d, not converted.\n",
self, is_cmd ? "command" : "operator", get_tok_name(tok, is_cmd), tok, lineno);
+ errs++;
}
int is_supported_cmd(unsigned char tok, int lineno) {
@@ -224,7 +227,7 @@ CALLBACK(conv_cmd) {
program[pos] = cmd_table[tok];
if(verbose && tok != program[pos])
- fprintf(stderr, "cmd tok \"%s\" ($%02x) converted to $%02x at line %d, pos $%04x\n",
+ fprintf(stderr, "command \"%s\" ($%02x) converted to $%02x at line %d, pos $%04x\n",
get_tok_name(tok, 1), tok, program[pos], lineno, pos);
}
@@ -235,7 +238,7 @@ CALLBACK(conv_op) {
program[pos] = op_table[tok];
if(verbose && tok != program[pos])
- fprintf(stderr, "op tok \"%s\" ($%02x) converted to $%02x at line %d, pos $%04x\n",
+ fprintf(stderr, "operator \"%s\" ($%02x) converted to $%02x at line %d, pos $%04x\n",
get_tok_name(tok, 0), tok, program[pos], lineno, pos);
}
@@ -259,5 +262,11 @@ int main(int argc, char **argv) {
open_output(output_filename);
writefile();
+ if(errs) {
+ fprintf(stderr, "%s: program has %d invalid tokens; BASIC/A+ won't RUN it.\n",
+ self, errs);
+ return 1;
+ }
+
return 0;
}