From 5a5a7137e84127b98391691ecab91dac1f666e81 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 21 Jul 2024 16:44:51 -0400 Subject: bas2aplus: error exit and message on bad tokens; tweak doc. --- bas2aplus.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'bas2aplus.c') 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; } -- cgit v1.2.3