// Parse {block} [else {block}] static void parse_block_else_block(bool parse_first) { // Parse first block. // If it's not correctly terminated, return immediately (because // in that case, there's no use in checking for an "else" part). if(skip_or_parse_block(parse_first)) return; // now GotByte = '}'. Check for "else" part. // If end of statement, return immediately. NEXTANDSKIPSPACE(); if(GotByte == CHAR_EOS) return; // read keyword and check whether really "else" if(Input_read_and_lower_keyword()) { if(strcmp(GlobalDynaBuf->buffer, "else")) Throw_error(exception_syntax); else { SKIPSPACE(); if(GotByte != CHAR_SOB) Throw_serious_error(exception_no_left_brace); skip_or_parse_block(!parse_first); // now GotByte = '}' GetByte(); } } Input_ensure_EOS(); }
// Try to read a condition into DynaBuf and store copy pointer in // given loopcond_t structure. // If no condition given, NULL is written to structure. // Call with GotByte = first interesting character static void store_condition(loopcond_t* condition, char terminator) { void* node_body; // write line number condition->line = Input_now->line_number; // Check for empty condition if(GotByte == terminator) { // Write NULL condition, then return condition->body = NULL; return; } // Seems as if there really *is* a condition. // Read UNTIL/WHILE keyword if(Input_read_and_lower_keyword()) { // Search for new tree item if(!Tree_easy_scan(condkey_tree, &node_body, GlobalDynaBuf)) { Throw_error(exception_syntax); condition->body = NULL; return; } condition->type = (enum cond_key_t) node_body; // Write given condition into buffer SKIPSPACE(); DYNABUF_CLEAR(GlobalDynaBuf); Input_until_terminator(terminator); DynaBuf_append(GlobalDynaBuf, CHAR_EOS);// ensure terminator condition->body = DynaBuf_get_copy(GlobalDynaBuf); } return; }
// Select CPU ("!cpu" pseudo opcode) static enum eos_t PO_cpu(void) { struct cpu_t* cpu_buffer = CPU_now; // remember current cpu if(Input_read_and_lower_keyword()) if(!CPU_find_cpu_struct(&CPU_now)) Throw_error("Unknown processor."); // If there's a block, parse that and then restore old value! if(Parse_optional_block()) CPU_now = cpu_buffer; return(ENSURE_EOS); }