From e65557d40df45f27caa8177cd31f88c5f0611eec Mon Sep 17 00:00:00 2001 From: night0721 Date: Sat, 18 May 2024 19:07:13 +0100 Subject: [PATCH] format --- lexer.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lexer.c b/lexer.c index fdc98e8..ab7c694 100644 --- a/lexer.c +++ b/lexer.c @@ -5,14 +5,15 @@ #include "lexer.h" -Token *lexer(char *buf){ +Token *lexer(char *buf) +{ char *current = strdup(buf); int current_index = 0, tokens_index = 0; Token *tokens = malloc(sizeof(Token) * 1024); - while(current[current_index] != '\0'){ + while(current[current_index] != '\0') { Token *token = NULL; - if(current[current_index] == ';'){ + if(current[current_index] == ';') { token = malloc(sizeof(Token)); char *value = malloc(2 * sizeof(char)); value[0] = current[current_index]; @@ -22,7 +23,7 @@ Token *lexer(char *buf){ tokens[tokens_index] = *token; tokens_index++; printf("FOUND SEMICOLON\n"); - } else if(current[current_index] == '('){ + } else if(current[current_index] == '(') { token = malloc(sizeof(Token)); char *value = malloc(2 * sizeof(char)); value[0] = current[current_index]; @@ -32,7 +33,7 @@ Token *lexer(char *buf){ tokens[tokens_index] = *token; tokens_index++; printf("FOUND OPEN PAREN\n"); - } else if(current[current_index] == ')'){ + } else if(current[current_index] == ')') { token = malloc(sizeof(Token)); char *value = malloc(2 * sizeof(char)); value[0] = current[current_index]; @@ -42,12 +43,12 @@ Token *lexer(char *buf){ tokens[tokens_index] = *token; tokens_index++; printf("FOUND CLOSE PAREN\n"); - } else if(isdigit(current[current_index])){ + } else if(isdigit(current[current_index])) { token = generate_number(current, ¤t_index); tokens[tokens_index] = *token; tokens_index++; current_index--; - } else if(isalpha(current[current_index])){ + } else if(isalpha(current[current_index])) { token = generate_keyword(current, ¤t_index); tokens[tokens_index] = *token; tokens_index++;