From ae1ef64838a94d5a811573468fbc581b43d84c33 Mon Sep 17 00:00:00 2001 From: Richard Thier Date: Wed, 25 Sep 2024 23:37:57 +0200 Subject: [PATCH] utilized GOTO well --- engine/slc.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/engine/slc.h b/engine/slc.h index 8442ec9..61740dc 100644 --- a/engine/slc.h +++ b/engine/slc.h @@ -342,12 +342,17 @@ static inline void slc( const char *prefix, const char *ender, const char *varprefix) { + slc_state state = SLC_START; int singleline_comment_len = strlen(singleline_comment); 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; while(((c = code_src()) != 0)) { + process_char: switch(state) { case SLC_START: int comment_i = 0; @@ -369,14 +374,17 @@ static inline void slc( state, c, prefix); - } + } else goto process_char; // new state might need 'c' too /* state -> word_name */ if(state == SLC_START) { state = slc_word_name_statechange( state, c, 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; case SLC_COMMENT: break;