diff options
| author | B. Watson <urchlay@slackware.uk> | 2025-03-04 18:18:25 -0500 | 
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2025-03-04 18:18:25 -0500 | 
| commit | 1eb3f57437062efaee684fe7b91d9899f9359044 (patch) | |
| tree | 7e95709c8555e49129f7d8829c8762c5f47213d2 | |
| parent | 77f332623bae031c373f7014f8b3474a3f9c2b95 (diff) | |
| download | bw-atari8-tools-1eb3f57437062efaee684fe7b91d9899f9359044.tar.gz | |
listamsb: list_*() functions.
| -rw-r--r-- | listamsb.c | 25 | 
1 files changed, 21 insertions, 4 deletions
| @@ -89,6 +89,7 @@ int warnings =    0;  int proglen =     0;  int linecount =   0;  int header_read = 0; +int printing    = 0;  FILE *infile;  FILE *outfile; @@ -255,10 +256,28 @@ void read_header(void) {  }  void unknown_token(unsigned char byte, int ext) { +	if(!printing) return;  	fprintf(outfile, "<unknown %stoken ", (ext ? "extended " : ""));  	fprintf(outfile, "%s%02x>", (ext ? "$ff ": ""), byte);  } +void list_char(unsigned char c) { +	if(printing) fputc(c, outfile); +} + +void list_token(unsigned char c) { +	if(printing) fputs(std_tokens[byte - MIN_STD_TOK], outfile); +} + +void list_ext_token(unsigned char c) { +	if(printing) fputs(ext_tokens[byte - MIN_EXT_TOK], outfile); +} + +void list_lineno(int l) { +	/* note that AMSB always puts a space after the line number in LIST */ +	if(printing) fprintf(outfile, "%d ", lineno); +} +  /* meat and potatoes. does the actual detokenizing. gets called once     per line of code. returns false when it hits the last line, or     true if there are more lines. */ @@ -266,7 +285,6 @@ int next_line(void) {  	static int last_lineno = -1;  	static int last_ptr = -1;  	int ptr, lineno, was_ff, was_colon, in_string, in_comment, offset, len; -	int printing;  	unsigned char byte;  	offset = bytes_read; @@ -310,7 +328,6 @@ int next_line(void) {  	last_lineno = lineno; -	/* note that AMSB always puts a space after the line number in LIST */  	if(printing) fprintf(outfile, "%d ", lineno);  	was_ff = 0; @@ -368,7 +385,7 @@ int next_line(void) {  				if(printing) fputs(ext_tokens[byte - MIN_EXT_TOK], outfile);  			} else {  				if(printing) unknown_token(byte, 1); -				warnings++; +				warn("unknown extended token $ff $%02x at line %d", byte, lineno);  			}  			was_ff = 0;  		} else if(byte == 0xff) { @@ -382,7 +399,7 @@ int next_line(void) {  		} else if(byte >= 0x80) {  			/* invalid token */  			if(printing) unknown_token(byte, 0); -			warnings++; +			warn("unknown token $%02x at line %d", byte, lineno);  		} else {  			/* null byte means the line of code is done */  			if(!byte) break; | 
