utilized GOTO well

This commit is contained in:
Richard Thier 2024-09-25 23:37:57 +02:00
parent f83fd990f8
commit ae1ef64838

View File

@ -342,12 +342,17 @@ static inline void slc(
const char *prefix, const char *prefix,
const char *ender, const char *ender,
const char *varprefix) { const char *varprefix) {
slc_state state = SLC_START; slc_state state = SLC_START;
int singleline_comment_len = strlen(singleline_comment); int singleline_comment_len = strlen(singleline_comment);
int multiline_comment_opener_len = strlen(multiline_comment_opener); int multiline_comment_opener_len = strlen(multiline_comment_opener);
// TODO: Count line numbers
// TODO: Handle/count indentation for better error messages
uint8_t c = 0; uint8_t c = 0;
while(((c = code_src()) != 0)) { while(((c = code_src()) != 0)) {
process_char:
switch(state) { switch(state) {
case SLC_START: case SLC_START:
int comment_i = 0; int comment_i = 0;
@ -369,14 +374,17 @@ static inline void slc(
state, state,
c, c,
prefix); prefix);
} } else goto process_char; // new state might need 'c' too
/* state -> word_name */ /* state -> word_name */
if(state == SLC_START) { if(state == SLC_START) {
state = slc_word_name_statechange( state = slc_word_name_statechange(
state, state,
c, c,
prefix); prefix);
} if(state != SLC_START) goto process_char; // new state might need 'c' too
} else goto process_char; // new state might need 'c' too
// Step to read next character
break; break;
case SLC_COMMENT: case SLC_COMMENT:
break; break;