Removed a keyword tree with only two entries ("while" and "until") - that was just silly.

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@43 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye
2014-11-25 16:15:22 +00:00
parent 653ce7549c
commit ded7f1a065
3 changed files with 22 additions and 35 deletions

View File

@@ -17,7 +17,7 @@
#define RELEASE "0.95.3" // update before release (FIXME) #define RELEASE "0.95.3" // update before release (FIXME)
#define CODENAME "Fenchurch" // update before release #define CODENAME "Fenchurch" // update before release
#define CHANGE_DATE "23 Nov" // update before release #define CHANGE_DATE "25 Nov" // update before release
#define CHANGE_YEAR "2014" // update before release #define CHANGE_YEAR "2014" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/" // FIXME //#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/" // FIXME
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME #define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME

View File

@@ -28,22 +28,11 @@
struct loop_condition { struct loop_condition {
int line; // original line number int line; // original line number
int invert; // actually bool (0 for WHILE, 1 for UNTIL) int is_until; // actually bool (0 for WHILE, 1 for UNTIL)
char *body; // pointer to actual expression char *body; // pointer to actual expression
}; };
// variables
// predefined stuff
static struct ronode *condkey_tree = NULL; // tree to hold UNTIL and WHILE
static struct ronode condkeys[] = {
PREDEFNODE("until", TRUE), // UNTIL inverts the condition
PREDEFLAST("while", FALSE), // WHILE does not change the condition
// ^^^^ this marks the last element
};
// helper functions for "!for" and "!do" // helper functions for "!for" and "!do"
// parse a loop body (could also be used for macro body) // parse a loop body (could also be used for macro body)
@@ -64,28 +53,25 @@ static void parse_ram_block(int line_number, char *body)
// call with GotByte = first interesting character // call with GotByte = first interesting character
static void store_condition(struct loop_condition *condition, char terminator) static void store_condition(struct loop_condition *condition, char terminator)
{ {
void *node_body;
// write line number // write line number
condition->line = Input_now->line_number; condition->line = Input_now->line_number;
// Check for empty condition // set defaults
if (GotByte == terminator) { condition->is_until = FALSE;
// Write NULL condition, then return condition->body = NULL;
condition->invert = FALSE; // check for empty condition
condition->body = NULL; if (GotByte == terminator)
return; return;
}
// Seems as if there really *is* a condition. // seems as if there really *is* a condition, so check for until/while
// Read UNTIL/WHILE keyword
if (Input_read_and_lower_keyword()) { if (Input_read_and_lower_keyword()) {
// Search for new tree item if (strcmp(GlobalDynaBuf->buffer, "while") == 0) {
if (!Tree_easy_scan(condkey_tree, &node_body, GlobalDynaBuf)) { //condition.is_until = FALSE;
} else if (strcmp(GlobalDynaBuf->buffer, "until") == 0) {
condition->is_until = TRUE;
} else {
Throw_error(exception_syntax); Throw_error(exception_syntax);
condition->invert = FALSE;
condition->body = NULL;
return; return;
} }
condition->invert = (int) node_body;
// Write given condition into buffer // Write given condition into buffer
SKIPSPACE(); SKIPSPACE();
DYNABUF_CLEAR(GlobalDynaBuf); DYNABUF_CLEAR(GlobalDynaBuf);
@@ -112,7 +98,7 @@ static int check_condition(struct loop_condition *condition)
expression = ALU_defined_int(); expression = ALU_defined_int();
if (GotByte) if (GotByte)
Throw_serious_error(exception_syntax); Throw_serious_error(exception_syntax);
return condition->invert ? !expression : !!expression; return condition->is_until ? !expression : !!expression;
} }
@@ -127,9 +113,9 @@ static enum eos PO_do(void) // Now GotByte = illegal char
int go_on, int go_on,
loop_start; // line number of loop pseudo opcode loop_start; // line number of loop pseudo opcode
// Init // Init
condition1.invert = FALSE; condition1.is_until = FALSE;
condition1.body = NULL; condition1.body = NULL;
condition2.invert = FALSE; condition2.is_until = FALSE;
condition2.body = NULL; condition2.body = NULL;
// Read head condition to buffer // Read head condition to buffer
@@ -298,11 +284,13 @@ static void parse_block_else_block(int parse_first)
// in that case, there's no use in checking for an "else" part). // in that case, there's no use in checking for an "else" part).
if (skip_or_parse_block(parse_first)) if (skip_or_parse_block(parse_first))
return; return;
// now GotByte = '}'. Check for "else" part. // now GotByte = '}'. Check for "else" part.
// If end of statement, return immediately. // If end of statement, return immediately.
NEXTANDSKIPSPACE(); NEXTANDSKIPSPACE();
if (GotByte == CHAR_EOS) if (GotByte == CHAR_EOS)
return; return;
// read keyword and check whether really "else" // read keyword and check whether really "else"
if (Input_read_and_lower_keyword()) { if (Input_read_and_lower_keyword()) {
if (strcmp(GlobalDynaBuf->buffer, "else")) { if (strcmp(GlobalDynaBuf->buffer, "else")) {
@@ -334,7 +322,7 @@ static enum eos PO_if(void) // Now GotByte = illegal char
// conditional assembly ("!ifdef" and "!ifndef"). Has to be re-entrant. // conditional assembly ("!ifdef" and "!ifndef"). Has to be re-entrant.
static enum eos ifdef_ifndef(int invert) // Now GotByte = illegal char static enum eos ifdef_ifndef(int is_ifndef) // Now GotByte = illegal char
{ {
struct rwnode *node; struct rwnode *node;
struct symbol *symbol; struct symbol *symbol;
@@ -355,7 +343,7 @@ static enum eos ifdef_ifndef(int invert) // Now GotByte = illegal char
} }
SKIPSPACE(); SKIPSPACE();
// if "ifndef", invert condition // if "ifndef", invert condition
if (invert) if (is_ifndef)
defined = !defined; defined = !defined;
if (GotByte != CHAR_SOB) if (GotByte != CHAR_SOB)
return defined ? PARSE_REMAINDER : SKIP_REMAINDER; return defined ? PARSE_REMAINDER : SKIP_REMAINDER;
@@ -469,6 +457,5 @@ static struct ronode pseudo_opcodes[] = {
// register pseudo opcodes and build keyword tree for until/while // register pseudo opcodes and build keyword tree for until/while
void Flow_init(void) void Flow_init(void)
{ {
Tree_add_table(&condkey_tree, condkeys);
Tree_add_table(&pseudo_opcode_tree, pseudo_opcodes); Tree_add_table(&pseudo_opcode_tree, pseudo_opcodes);
} }

View File

@@ -68,7 +68,7 @@
#define MAYBE_1_2_3 (MVALUE_FORCE08 | MVALUE_FORCE16 | MVALUE_FORCE24) #define MAYBE_1_2_3 (MVALUE_FORCE08 | MVALUE_FORCE16 | MVALUE_FORCE24)
// The mnemonics are split up into groups, each group has its own function to be dealt with: // The mnemonics are split up into groups, each group has its own function to be dealt with:
enum mnemogroup_t { enum mnemogroup {
GROUP_ACCU, // main accumulator stuff, plus PEI Byte value = table index GROUP_ACCU, // main accumulator stuff, plus PEI Byte value = table index
GROUP_MISC, // read-modify-write and others Byte value = table index GROUP_MISC, // read-modify-write and others Byte value = table index
GROUP_ALLJUMPS, // the jump instructions Byte value = table index GROUP_ALLJUMPS, // the jump instructions Byte value = table index