aboutsummaryrefslogtreecommitdiffstats
path: root/src/frontend/lexer.c
diff options
context:
space:
mode:
authorGalin Simeonov <gts@volconst.com>2021-06-03 12:38:37 +0300
committerGalin Simeonov <gts@volconst.com>2021-07-15 18:04:02 +0300
commit76fc38b3cdfded2911b464baa7b182b5102318d1 (patch)
tree389223f76086bff07a3cd762683e5a16d34d12d2 /src/frontend/lexer.c
parent85b23fbee717f047af5a89eac6f4dba8e7812524 (diff)
downloadMEGATRON-76fc38b3cdfded2911b464baa7b182b5102318d1.tar.gz
work on generated C code
Diffstat (limited to 'src/frontend/lexer.c')
-rw-r--r--src/frontend/lexer.c18
1 files changed, 18 insertions, 0 deletions
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;i<token->size;++i)
+ token->data[i]=toupper(token->data[i]);
+}
#endif