internal cleanup for next change

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@193 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye
2020-05-27 17:32:48 +00:00
parent 78e7c32507
commit a6eae58032
6 changed files with 29 additions and 37 deletions

View File

@@ -480,7 +480,7 @@ static const char *long_option(const char *string)
config.segment_warning_is_error = TRUE; config.segment_warning_is_error = TRUE;
else if (strcmp(string, OPTION_TEST) == 0) { else if (strcmp(string, OPTION_TEST) == 0) {
if (config.test_new_features) if (config.test_new_features)
config.backslash_escaping = TRUE; config.wanted_version = VER_FUTURE; // giving "--test" twice enables every new feature
config.test_new_features = TRUE; config.test_new_features = TRUE;
} PLATFORM_LONGOPTION_CODE } PLATFORM_LONGOPTION_CODE
else if (strcmp(string, OPTION_COLOR) == 0) else if (strcmp(string, OPTION_COLOR) == 0)
@@ -537,7 +537,7 @@ static char short_option(const char *argument)
config.warn_on_indented_labels = FALSE; config.warn_on_indented_labels = FALSE;
goto done; goto done;
} else if (strcmp(argument + 1, OPTIONWNO_OLD_FOR) == 0) { } else if (strcmp(argument + 1, OPTIONWNO_OLD_FOR) == 0) {
config.warn_on_old_for = FALSE; config.wanted_version = VER_NEWFORSYNTAX - 1;
goto done; goto done;
} else if (strcmp(argument + 1, OPTIONWTYPE_MISMATCH) == 0) { } else if (strcmp(argument + 1, OPTIONWTYPE_MISMATCH) == 0) {
config.warn_on_type_mismatch = TRUE; config.warn_on_type_mismatch = TRUE;
@@ -592,36 +592,27 @@ int main(int argc, const char *argv[])
TODO - maybe add a "use version" switch to ease assembling old sources? TODO - maybe add a "use version" switch to ease assembling old sources?
relevant changes are: relevant changes are:
"0.05" v0.05:
...would be the syntax before any changes ...would be the syntax before any changes
(how was offset assembly ended? '*' in a line on its own?) (how was offset assembly ended? '*' in a line on its own?)
BIT without any arg would output $2c, masking the next two bytes BIT without any arg would output $2c, masking the next two bytes
"0.07" v0.07:
"leading zeroes" info is now stored in symbols as well "leading zeroes" info is now stored in symbols as well
changed argument order of mvp/mvn changed argument order of mvp/mvn
!cbm outputs warning to use !ct pet instead !cbm outputs warning to use !ct pet instead
!end changed to !eof !end changed to !eof
*= is now segment change instead of offset assembly *= is now segment change instead of offset assembly
added !pseudopc/!realpc added !pseudopc/!realpc
"0.86"
!pseudopc/!realpc gives a warning to use !pseudopc{} instead config->wanted_version =
"0.89" 8600 // v0.86 make !pseudopc/!realpc give a warning to use !pseudopc{} instead
>> now does ASR everywhere, added >>> as LSR VER_0_93 9300 // v0.93 allowed *= inside offset assembly blocks
numbers before mnemonics are no longer interpreted as labels VER_RIGHTASSOCIATIVEPOWEROF 9406 // v0.94.6 made "power of" operator right-associative
"0.93" 9408 // v0.94.8 disabled !cbm, !pseudopc/!realpc, !subzone
*= no longer ends offset assembly VER_NEWFORSYNTAX 9412 // v0.94.12 introduced the new "!for" syntax
"0.94.6" 9502 // v0.95.2 changed ANC#8 from 0x2b to 0x0b
powerof is now right-associative VER_BACKSLASHESCAPING ? // not yet: backslash escaping (and therefore strings)
"0.94.8" VER_FUTURE 32767
disabled !cbm
disabled !pseudopc/!realpc
disabled !subzone
"0.94.12"
new !for syntax
"0.95.2"
changed ANC#8 from 0x2b to 0x0b
"future"
backslash escaping (= strings)
TODO: paths should be relative to file, not start dir TODO: paths should be relative to file, not start dir
TODO: ignore leading zeroes? TODO: ignore leading zeroes?
*/ */

View File

@@ -406,7 +406,7 @@ static void parse_quoted(char closing_quote)
// without backslash escaping, both ' and " are used for single // without backslash escaping, both ' and " are used for single
// characters. // characters.
// with backslash escaping, ' is for characters and " is for strings: // with backslash escaping, ' is for characters and " is for strings:
if ((closing_quote == '"') && (config.backslash_escaping)) { if ((closing_quote == '"') && (config.wanted_version >= VER_BACKSLASHESCAPING)) {
// string ////////////////////////////////// // string //////////////////////////////////
string_prepare_string(&arg_stack[arg_sp], GlobalDynaBuf->size); // create string object and put on arg stack string_prepare_string(&arg_stack[arg_sp], GlobalDynaBuf->size); // create string object and put on arg stack
memcpy(arg_stack[arg_sp].u.string->payload, GLOBALDYNABUF_CURRENT, GlobalDynaBuf->size); // copy payload memcpy(arg_stack[arg_sp].u.string->payload, GLOBALDYNABUF_CURRENT, GlobalDynaBuf->size); // copy payload
@@ -1941,7 +1941,7 @@ static void try_to_reduce_stacks(struct expression *expression)
// previous operator has same priority as current one? then check associativity // previous operator has same priority as current one? then check associativity
if ((previous_op->priority == current_op->priority) if ((previous_op->priority == current_op->priority)
&& (current_op->priority == PRIO_POWEROF) && (current_op->priority == PRIO_POWEROF)
&& (config.right_associative_powerof)) { && (config.wanted_version >= VER_RIGHTASSOCIATIVEPOWEROF)) {
alu_state = STATE_EXPECT_ARG_OR_MONADIC_OP; alu_state = STATE_EXPECT_ARG_OR_MONADIC_OP;
return; return;
} }

View File

@@ -121,17 +121,15 @@ void config_default(struct config *conf)
conf->pseudoop_prefix = '!'; // can be changed to '.' by CLI switch conf->pseudoop_prefix = '!'; // can be changed to '.' by CLI switch
conf->process_verbosity = 0; // level of additional output conf->process_verbosity = 0; // level of additional output
conf->warn_on_indented_labels = TRUE; // warn if indented label is encountered conf->warn_on_indented_labels = TRUE; // warn if indented label is encountered
conf->warn_on_old_for = TRUE; // warn if "!for" with old syntax is found
conf->warn_on_type_mismatch = FALSE; // use type-checking system conf->warn_on_type_mismatch = FALSE; // use type-checking system
conf->max_errors = MAXERRORS; // errors before giving up conf->max_errors = MAXERRORS; // errors before giving up
conf->format_msvc = FALSE; // enabled by --msvc conf->format_msvc = FALSE; // enabled by --msvc
conf->format_color = FALSE; // enabled by --color conf->format_color = FALSE; // enabled by --color
conf->msg_stream = stderr; // set to stdout by --use-stdout conf->msg_stream = stderr; // set to stdout by --use-stdout
conf->right_associative_powerof = TRUE; // TODO - add switch to disable
conf->honor_leading_zeroes = TRUE; // disabled by --ignore-zeroes conf->honor_leading_zeroes = TRUE; // disabled by --ignore-zeroes
conf->segment_warning_is_error = FALSE; // enabled by --strict-segments TODO - toggle default? conf->segment_warning_is_error = FALSE; // enabled by --strict-segments TODO - toggle default?
conf->test_new_features = FALSE; // enabled by --test conf->test_new_features = FALSE; // enabled by --test
conf->backslash_escaping = FALSE; // enabled by --test --test conf->wanted_version = VER_NEWFORSYNTAX; // TODO - add switch to change
} }
// memory allocation stuff // memory allocation stuff

View File

@@ -66,17 +66,20 @@ struct config {
char pseudoop_prefix; // '!' or '.' char pseudoop_prefix; // '!' or '.'
int process_verbosity; // level of additional output int process_verbosity; // level of additional output
boolean warn_on_indented_labels; // warn if indented label is encountered boolean warn_on_indented_labels; // warn if indented label is encountered
boolean warn_on_old_for; // warn if "!for" with old syntax is found
boolean warn_on_type_mismatch; // use type-checking system boolean warn_on_type_mismatch; // use type-checking system
signed long max_errors; // errors before giving up signed long max_errors; // errors before giving up
boolean format_msvc; // enabled by --msvc boolean format_msvc; // enabled by --msvc
boolean format_color; // enabled by --color boolean format_color; // enabled by --color
FILE *msg_stream; // defaults to stderr, changed to stdout by --use-stdout FILE *msg_stream; // defaults to stderr, changed to stdout by --use-stdout
boolean right_associative_powerof; // TRUE (TODO - add switch to disable)
boolean honor_leading_zeroes; // TRUE, disabled by --ignore-zeroes boolean honor_leading_zeroes; // TRUE, disabled by --ignore-zeroes
boolean segment_warning_is_error; // FALSE, enabled by --strict-segments boolean segment_warning_is_error; // FALSE, enabled by --strict-segments
boolean test_new_features; // FALSE, enabled by --test boolean test_new_features; // FALSE, enabled by --test
boolean backslash_escaping; // FALSE, enabled by --test --test int wanted_version;
#define VER_0_93 9300 // v0.93
#define VER_RIGHTASSOCIATIVEPOWEROF 9406 // v0.94.6 made "power of" operator right-associative
#define VER_NEWFORSYNTAX 9412 // v0.94.12 introduced the new "!for" syntax
#define VER_BACKSLASHESCAPING 10000 // not yet: backslash escaping
#define VER_FUTURE 32767
}; };
extern struct config config; extern struct config config;

View File

@@ -371,7 +371,7 @@ int Input_quoted_to_dynabuf(char closing_quote)
if (GotByte == closing_quote) if (GotByte == closing_quote)
return 0; // ok return 0; // ok
if ((GotByte == '\\') && (config.backslash_escaping)) if ((GotByte == '\\') && (config.wanted_version >= VER_BACKSLASHESCAPING))
escaped = TRUE; escaped = TRUE;
} }
DYNABUF_APPEND(GlobalDynaBuf, GotByte); DYNABUF_APPEND(GlobalDynaBuf, GotByte);
@@ -387,7 +387,7 @@ int Input_unescape_dynabuf(int read_index)
char byte; char byte;
boolean escaped; boolean escaped;
if (!config.backslash_escaping) if (config.wanted_version < VER_BACKSLASHESCAPING)
return 0; // ok return 0; // ok
write_index = read_index; write_index = read_index;

View File

@@ -377,7 +377,7 @@ static enum eos encode_string(const struct encoder *inner_encoder, char xor)
// make given encoder the current one (for ALU-parsed values) // make given encoder the current one (for ALU-parsed values)
encoder_current = inner_encoder; encoder_current = inner_encoder;
do { do {
if (GotByte == '"') { // FIXME - add "&& !config.backslash_escaping", otherwise stuff like "string"[index] will not work if (GotByte == '"') { // FIXME - add "&& (config.wanted_version < VER_BACKSLASHESCAPING)", otherwise stuff like "string"[index] will not work
DYNABUF_CLEAR(GlobalDynaBuf); DYNABUF_CLEAR(GlobalDynaBuf);
if (Input_quoted_to_dynabuf('"')) if (Input_quoted_to_dynabuf('"'))
return SKIP_REMAINDER; // unterminated or escaping error return SKIP_REMAINDER; // unterminated or escaping error
@@ -1039,7 +1039,7 @@ static enum eos po_for(void) // now GotByte = illegal char
loop.counter.addr_refs = intresult.addr_refs; loop.counter.addr_refs = intresult.addr_refs;
if (Input_accept_comma()) { if (Input_accept_comma()) {
loop.use_old_algo = FALSE; // new format - yay! loop.use_old_algo = FALSE; // new format - yay!
if (!config.warn_on_old_for) if (config.wanted_version < VER_NEWFORSYNTAX)
Throw_first_pass_warning("Found new \"!for\" syntax."); Throw_first_pass_warning("Found new \"!for\" syntax.");
loop.counter.first = intresult.val.intval; // use first argument loop.counter.first = intresult.val.intval; // use first argument
ALU_defined_int(&intresult); // read second argument ALU_defined_int(&intresult); // read second argument
@@ -1052,7 +1052,7 @@ static enum eos po_for(void) // now GotByte = illegal char
loop.counter.increment = (loop.counter.last < loop.counter.first) ? -1 : 1; loop.counter.increment = (loop.counter.last < loop.counter.first) ? -1 : 1;
} else { } else {
loop.use_old_algo = TRUE; // old format - booo! loop.use_old_algo = TRUE; // old format - booo!
if (config.warn_on_old_for) if (config.wanted_version >= VER_NEWFORSYNTAX)
Throw_first_pass_warning("Found old \"!for\" syntax."); Throw_first_pass_warning("Found old \"!for\" syntax.");
if (intresult.val.intval < 0) if (intresult.val.intval < 0)
Throw_serious_error("Loop count is negative."); Throw_serious_error("Loop count is negative.");
@@ -1174,7 +1174,7 @@ static enum eos throw_string(const char prefix[], void (*fn)(const char *))
DYNABUF_CLEAR(user_message); DYNABUF_CLEAR(user_message);
DynaBuf_add_string(user_message, prefix); DynaBuf_add_string(user_message, prefix);
do { do {
if ((GotByte == '"') && !config.backslash_escaping) { if ((GotByte == '"') && (config.wanted_version < VER_BACKSLASHESCAPING)) {
DYNABUF_CLEAR(GlobalDynaBuf); DYNABUF_CLEAR(GlobalDynaBuf);
if (Input_quoted_to_dynabuf('"')) if (Input_quoted_to_dynabuf('"'))
return SKIP_REMAINDER; // unterminated or escaping error return SKIP_REMAINDER; // unterminated or escaping error