From 76fc38b3cdfded2911b464baa7b182b5102318d1 Mon Sep 17 00:00:00 2001 From: Galin Simeonov Date: Thu, 3 Jun 2021 12:38:37 +0300 Subject: work on generated C code --- src/frontend/lexer.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/frontend/lexer.c') diff --git a/src/frontend/lexer.c b/src/frontend/lexer.c index 6dc348d..de8ff95 100644 --- a/src/frontend/lexer.c +++ b/src/frontend/lexer.c @@ -37,14 +37,26 @@ struct token* lex_step(struct Source *src,struct Translation_Data *translation_d return get_token(src->src+src->where_in_src-sizeof("on")+1,sizeof("on")-1,KW_ON,src->current_row,src->current_column); if(check_and_move_if_on_word("[",sizeof("[")-1,src,0)) return get_token(src->src+src->where_in_src-sizeof("[")+1,sizeof("[")-1,KW_OPEN_SQUARE,src->current_row,src->current_column); + if(check_and_move_if_on_word("(",sizeof("(")-1,src,0)) + return get_token(src->src+src->where_in_src-sizeof("(")+1,sizeof("(")-1,KW_OPEN_NORMAL,src->current_row,src->current_column); + if(check_and_move_if_on_word(")",sizeof(")")-1,src,0)) + return get_token(src->src+src->where_in_src-sizeof(")")+1,sizeof(")")-1,KW_CLOSE_NORMAL,src->current_row,src->current_column); if(check_and_move_if_on_word(",",sizeof(",")-1,src,0)) return get_token(src->src+src->where_in_src-sizeof(",")+1,sizeof(",")-1,KW_COMMA,src->current_row,src->current_column); + if(check_and_move_if_on_word(".",sizeof(".")-1,src,0)) + return get_token(src->src+src->where_in_src-sizeof(".")+1,sizeof(".")-1,KW_DOT,src->current_row,src->current_column); if(check_and_move_if_on_word("]",sizeof("]")-1,src,0)) return get_token(src->src+src->where_in_src-sizeof("]")+1,sizeof("]")-1,KW_CLOSE_SQUARE,src->current_row,src->current_column); if(check_and_move_if_on_word(";",sizeof(";")-1,src,0)) return get_token(src->src+src->where_in_src-sizeof(";")+1,sizeof(";")-1,KW_SEMI_COLUMN,src->current_row,src->current_column); if(check_and_move_if_on_word("|",sizeof("|")-1,src,0)) return get_token(src->src+src->where_in_src-sizeof("|")+1,sizeof("|")-1,KW_PIPE,src->current_row,src->current_column); + if(check_and_move_if_on_word("||",sizeof("||")-1,src,0)) + return get_token(src->src+src->where_in_src-sizeof("||")+1,sizeof("||")-1,KW_OR,src->current_row,src->current_column); + if(check_and_move_if_on_word("&&",sizeof("&&")-1,src,0)) + return get_token(src->src+src->where_in_src-sizeof("&&")+1,sizeof("&&")-1,KW_AND,src->current_row,src->current_column); + if(check_and_move_if_on_word("!",sizeof("!")-1,src,0)) + return get_token(src->src+src->where_in_src-sizeof("!")+1,sizeof("!")-1,KW_NOT,src->current_row,src->current_column); if(check_and_move_if_on_word("starting",sizeof("starting")-1,src,1)) return get_token(src->src+src->where_in_src-sizeof("starting")+1,sizeof("starting")-1,KW_STARTING,src->current_row,src->current_column); if(check_and_move_if_on_word("states",sizeof("states")-1,src,1)) @@ -157,4 +169,10 @@ void push_token_into_map(struct token *token,struct Map *map,void *thing) { Map_Push(map,token->data,token->size,thing); } +void id_token_to_upper_case(struct token *token) +{ + size_t i; + for(i=0;isize;++i) + token->data[i]=toupper(token->data[i]); +} #endif -- cgit v1.2.3