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;
else if (strcmp(string, OPTION_TEST) == 0) {
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;
} PLATFORM_LONGOPTION_CODE
else if (strcmp(string, OPTION_COLOR) == 0)
@ -537,7 +537,7 @@ static char short_option(const char *argument)
config.warn_on_indented_labels = FALSE;
goto done;
} else if (strcmp(argument + 1, OPTIONWNO_OLD_FOR) == 0) {
config.warn_on_old_for = FALSE;
config.wanted_version = VER_NEWFORSYNTAX - 1;
goto done;
} else if (strcmp(argument + 1, OPTIONWTYPE_MISMATCH) == 0) {
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?
relevant changes are:
"0.05"
v0.05:
...would be the syntax before any changes
(how was offset assembly ended? '*' in a line on its own?)
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
changed argument order of mvp/mvn
!cbm outputs warning to use !ct pet instead
!end changed to !eof
*= is now segment change instead of offset assembly
added !pseudopc/!realpc
"0.86"
!pseudopc/!realpc gives a warning to use !pseudopc{} instead
"0.89"
>> now does ASR everywhere, added >>> as LSR
numbers before mnemonics are no longer interpreted as labels
"0.93"
*= no longer ends offset assembly
"0.94.6"
powerof is now right-associative
"0.94.8"
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)
config->wanted_version =
8600 // v0.86 make !pseudopc/!realpc give a warning to use !pseudopc{} instead
VER_0_93 9300 // v0.93 allowed *= inside offset assembly blocks
VER_RIGHTASSOCIATIVEPOWEROF 9406 // v0.94.6 made "power of" operator right-associative
9408 // v0.94.8 disabled !cbm, !pseudopc/!realpc, !subzone
VER_NEWFORSYNTAX 9412 // v0.94.12 introduced the new "!for" syntax
9502 // v0.95.2 changed ANC#8 from 0x2b to 0x0b
VER_BACKSLASHESCAPING ? // not yet: backslash escaping (and therefore strings)
VER_FUTURE 32767
TODO: paths should be relative to file, not start dir
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
// characters.
// 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_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
@ -1941,7 +1941,7 @@ static void try_to_reduce_stacks(struct expression *expression)
// previous operator has same priority as current one? then check associativity
if ((previous_op->priority == current_op->priority)
&& (current_op->priority == PRIO_POWEROF)
&& (config.right_associative_powerof)) {
&& (config.wanted_version >= VER_RIGHTASSOCIATIVEPOWEROF)) {
alu_state = STATE_EXPECT_ARG_OR_MONADIC_OP;
return;
}

View File

@ -121,17 +121,15 @@ void config_default(struct config *conf)
conf->pseudoop_prefix = '!'; // can be changed to '.' by CLI switch
conf->process_verbosity = 0; // level of additional output
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->max_errors = MAXERRORS; // errors before giving up
conf->format_msvc = FALSE; // enabled by --msvc
conf->format_color = FALSE; // enabled by --color
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->segment_warning_is_error = FALSE; // enabled by --strict-segments TODO - toggle default?
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

View File

@ -66,17 +66,20 @@ struct config {
char pseudoop_prefix; // '!' or '.'
int process_verbosity; // level of additional output
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
signed long max_errors; // errors before giving up
boolean format_msvc; // enabled by --msvc
boolean format_color; // enabled by --color
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 segment_warning_is_error; // FALSE, enabled by --strict-segments
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;

View File

@ -371,7 +371,7 @@ int Input_quoted_to_dynabuf(char closing_quote)
if (GotByte == closing_quote)
return 0; // ok
if ((GotByte == '\\') && (config.backslash_escaping))
if ((GotByte == '\\') && (config.wanted_version >= VER_BACKSLASHESCAPING))
escaped = TRUE;
}
DYNABUF_APPEND(GlobalDynaBuf, GotByte);
@ -387,7 +387,7 @@ int Input_unescape_dynabuf(int read_index)
char byte;
boolean escaped;
if (!config.backslash_escaping)
if (config.wanted_version < VER_BACKSLASHESCAPING)
return 0; // ok
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)
encoder_current = inner_encoder;
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);
if (Input_quoted_to_dynabuf('"'))
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;
if (Input_accept_comma()) {
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.");
loop.counter.first = intresult.val.intval; // use first 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;
} else {
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.");
if (intresult.val.intval < 0)
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_add_string(user_message, prefix);
do {
if ((GotByte == '"') && !config.backslash_escaping) {
if ((GotByte == '"') && (config.wanted_version < VER_BACKSLASHESCAPING)) {
DYNABUF_CLEAR(GlobalDynaBuf);
if (Input_quoted_to_dynabuf('"'))
return SKIP_REMAINDER; // unterminated or escaping error