diff options
| author | B. Watson <urchlay@slackware.uk> | 2024-07-17 16:31:23 -0400 | 
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2024-07-17 16:31:23 -0400 | 
| commit | 06106300e03dabe51f8ba7805984433730de2fe4 (patch) | |
| tree | 42beaf30cb63bf8374aa302b5f6b469c2c92467d | |
| parent | 271c293f1a8a1ba3316d6b9fecb955d336441fd0 (diff) | |
| download | bw-atari8-tools-06106300e03dabe51f8ba7805984433730de2fe4.tar.gz | |
listbas: add -t (disable indent) option, though indentation not yet implemented. also add large commentary section.
| -rw-r--r-- | listbas.c | 56 | 
1 files changed, 52 insertions, 4 deletions
| @@ -78,6 +78,7 @@ int skip_lineno = 0;  /* 1 with -l */  int dump_tables = 0;  /* 1 with -D */  int autodetect  = 1;  /* 0 with -b */  int mixed_case  = 1;  /* 0 with -k, or if input is B_ATARI or B_APLUS */ +int indent =      1;  /* 0 with -t, or if input is B_ATARI */  /* change these with -c */  int color_cmd =       C_YELLOW; @@ -91,9 +92,11 @@ int color_varnames  = NO_COLOR;  const char *input_filename; -int badtok =      0; /* set to 1 if we find a bad token */ -int inv =         0; /* set to 1 when we're printing inverse */ -int cur_color =  -1; /* -1 = no color */ +int indent_level = 0; +int badtok =       0; /* set to 1 if we find a bad token */ +int inv =          0; /* set to 1 when we're printing inverse */ +int cur_color =   -1; /* -1 = no color */ +  FILE *outfh;  int parse_color(char c) { @@ -146,7 +149,7 @@ int get_bas_type(char *arg) {  }  void print_help(void) { -	printf("Usage: %s [-a|-d|-m|-x|-U] [-B] [-i] [-l] [-u] [-n|-C] [-v] [-c *colors*] [-k] <inputfile>\n", self); +	printf("Usage: %s [-a|-d|-m|-x|-U] [-B] [-i] [-l] [-u] [-n|-C] [-v] [-c *colors*] [-k] [-t] <inputfile>\n", self);  	printf("  -b <XX>: set BASIC type. XX is: a = atari, t = turbo, xl, xe, a+.\n");  	printf("  -U: output ATASCII as Unicode/UTF-8 (this is the default).\n");  	printf("  -a: output raw ATASCII.\n"); @@ -161,6 +164,7 @@ void print_help(void) {  	printf("  -u: use underline for inverse video.\n");  	printf("  -c: use custom colors (see man page).\n");  	printf("  -k: disable mixed case keywords for BXL/BXE (e.g. Print).\n"); +	printf("  -t: disable Turbo/BXL/BXE indentation.\n");  	printf("  -v: verbose.\n");  } @@ -478,6 +482,47 @@ CALLBACK(print_lineno) {  	if(color) color_off();  } +/* indentation is totally different between A+, BXL, and BXE. +   Turbo and BXE use the same indent style, but Turbo has more +   keywords that indent (e.g. REPEAT, DO). + +   A+ always indents on the lines after a WHILE or a FOR, unless there's +   a matching ENDWHILE or NEXT on the same line. It indents the lines +   after IF only if there's no THEN and no matching ENDIF on the +   same line. ENDWHILE, NEXT, ENDIF all un-undent one level. The style +   is that the the ending keyword (or ELSE) does NOT get unindented, +   itself: + +   WHILE 1 +     PRINT "OK" +     ENDWHILE +   PRINT "HEY" + +   That looks *wrong* to me (the ENDWHILE should line up with the WHILE), but +   that's how A+ works. + +  BXL's style is to indent the entire block to the same level: + +     While 1 +     Print "OK" +     Endwhile +   Print "HEY" + +   This applies even if the whole block's on one line: + +    ? "OK" +      For I=1 To 10:Next I +    ? "OK" + +BXE and Turbo work like modern style: the keywords that start and end the +block are not indented, only the lines between them. + +   While 1 +     Print "OK" +   Endwhile +   Print "HEY" + + */  CALLBACK(print_cmd) {  	const char *name; @@ -845,6 +890,9 @@ void init_bas_dialect() {  	if(bas_type == B_ATARI || bas_type == B_APLUS || bas_type == B_TURBO)  		mixed_case = 0; + +	if(bas_type == B_ATARI) +		indent = 0;  }  int main(int argc, char **argv) { | 
