//static void accept(int token) void accept(int token) { #if TEST char buf[10]; #endif if(token != tokenizer_token()) { #if TEST buf[0] = (token/10) + '0'; buf[1] = (token%10) + '0'; buf[2] = ' '; buf[3] = (current_token/10) + '0'; buf[4] = (current_token%10) + '0'; buf[5] = '\n'; buf[6] = 0x00; // printf(buf); // cputs_p(6,buf); glcd_PutsA(buf); #endif tokenizer_error_print(); ended = 1; glcd_DrawCursor(); // exit(1); } tokenizer_next(); }
/** * Umschalten des Programm-Kontextes * \param p_name Programmname */ void switch_proc(char * p_name) { botfs_file_descr_t new_prog; if (botfs_open(p_name, &new_prog, BOTFS_MODE_r, GET_MMC_BUFFER(ubasic_buffer)) != 0) { tokenizer_error_print(current_linenum, UNKNOWN_SUBPROC); ubasic_break(); } else { bot_ubasic_load_file(p_name, &new_prog); program_ptr = 0; tokenizer_init(program_ptr); } }
/*---------------------------------------------------------------------------*/ static void accept(int token) { if(token != tokenizer_token()) { DEBUG_PRINTF("Token not what was expected (expected %d, got %d)\n", token, tokenizer_token()); tokenizer_error_print(); exit(1); } DEBUG_PRINTF("Expected %d, got it\n", token); tokenizer_next(); }
/*---------------------------------------------------------------------------*/ static uint8_t accept_tok(uint8_t token) { if(token != current_token) { DEBUG_PRINTF("Token not what was expected (expected %d, got %d)\n", token, current_token); tokenizer_error_print(); exit(1); } DEBUG_PRINTF("Expected %d, got it\n", token); tokenizer_next(); /* This saves lots of extra calls - return the new token */ return current_token; }
static int search_cvars(const char *var_name) { int idx=0; // Variablenname in Tabelle suchen #if USE_PROGMEM while((int *)pgm_read_word(&cvars[idx].pvar) != NULL && strncasecmp_P(var_name, cvars[idx].var_name, MAX_NAME_LEN)) { idx++; } #else while(cvars[idx].pvar != NULL && strncasecmp(cvars[idx].var_name, var_name, MAX_NAME_LEN)) { idx++; } #endif // keinen Tabelleneintrag gefunden! #if USE_PROGMEM if ((int *)pgm_read_word(&cvars[idx].pvar) == NULL) { #else if (cvars[idx].pvar == NULL) { #endif tokenizer_error_print(current_linenum, UNKNOWN_CVAR_NAME); ubasic_break(); } return idx; } void vpoke_statement(void) { int idx=0; #if USE_PROGMEM int *var_temp; #endif accept(TOKENIZER_VPOKE); accept(TOKENIZER_LEFTPAREN); // Variablenname ermitteln if(tokenizer_token() == TOKENIZER_STRING) { tokenizer_next(); } idx=search_cvars(tokenizer_last_string_ptr()); accept(TOKENIZER_RIGHTPAREN); accept(TOKENIZER_EQ); #if USE_PROGMEM var_temp=(int *)pgm_read_word(&cvars[idx].pvar); *var_temp=expr(); #else *cvars[idx].pvar = expr(); #endif //tokenizer_next(); }
//static void statement(void) void statement(void) { int token; token = tokenizer_token(); switch(token) { case TOKENIZER_PRINT: print_statement(); break; case TOKENIZER_IF: if_statement(); break; case TOKENIZER_GOTO: goto_statement(); break; case TOKENIZER_GOSUB: gosub_statement(); break; case TOKENIZER_RETURN: return_statement(); break; case TOKENIZER_FOR: for_statement(); break; case TOKENIZER_NEXT: next_statement(); break; case TOKENIZER_END: end_statement(); break; case TOKENIZER_PSET: pset_statement(); break; case TOKENIZER_CLS: cls_statement(); break; case TOKENIZER_REFRESH: refresh_statement(); break; case TOKENIZER_LIST: list_statement(); break; case TOKENIZER_LOAD: load_statement(); break; case TOKENIZER_SAVE: save_statement(); break; case TOKENIZER_FILES: files_statement(); break; case TOKENIZER_PEEK: peek_statement(); break; case TOKENIZER_POKE: poke_statement(); break; case TOKENIZER_WAIT: wait_statement(); break; case TOKENIZER_INPUT: input_statement(); break; case TOKENIZER_INP: inp_statement(); break; case TOKENIZER_INR: inr_statement(); break; case TOKENIZER_INA: ina_statement(); break; case TOKENIZER_REM: rem_statement(); break; case TOKENIZER_RUN: run_statement(); break; case TOKENIZER_ERROR: tokenizer_error_print(); ended = 1; glcd_DrawCursor(); break; case TOKENIZER_LET: accept(TOKENIZER_LET); accept(TOKENIZER_VARIABLE); accept(TOKENIZER_CR); break; /* Fall through. */ case TOKENIZER_VARIABLE: let_statement(); break; default: exit(1); } }