From a26684a417729699e95b335a3d00798237ffba9b Mon Sep 17 00:00:00 2001 From: Galin Simeonov Date: Fri, 4 Jun 2021 16:42:52 +0300 Subject: added the if statement --- src/frontend/lexer.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/frontend/lexer.c') diff --git a/src/frontend/lexer.c b/src/frontend/lexer.c index 668d7cd..a832a17 100644 --- a/src/frontend/lexer.c +++ b/src/frontend/lexer.c @@ -8,7 +8,7 @@ #define LEX_ERROR(x) {push_lexing_error(x,src,translation_data); return get_token(src->src+src->where_in_src,0,KW_NOP,src->current_row,src->current_column);} /* - * placeholder very slow lexer that I will probabbly not replace + * placeholder very slow ( and very very bad ) lexer that I will probabbly not replace */ void lex(struct Queue *token_destination,struct Source *src,struct Translation_Data *translation_data) { @@ -69,9 +69,11 @@ struct token* lex_step(struct Source *src,struct Translation_Data *translation_d return get_token(src->src+src->where_in_src-sizeof("event")+1,sizeof("event")-1,KW_EVENT,src->current_row,src->current_column); if(check_and_move_if_on_word("transitions",sizeof("transitions")-1,src,1)) return get_token(src->src+src->where_in_src-sizeof("transitions")+1,sizeof("transitions")-1,KW_TRANSITIONS,src->current_row,src->current_column); + if(check_and_move_if_on_word("if",sizeof("if")-1,src,1)) + return get_token(src->src+src->where_in_src-sizeof("if")+1,sizeof("if")-1,KW_IF,src->current_row,src->current_column); - - + if(check_and_move_if_on_word("else",sizeof("else")-1,src,1)) + return get_token(src->src+src->where_in_src-sizeof("else")+1,sizeof("else")-1,KW_ELSE,src->current_row,src->current_column); -- cgit v1.2.3