From 48f6a2e757ffa49f4a5676e29f5fff935660b6a1 Mon Sep 17 00:00:00 2001 From: c+1 Date: Thu, 4 May 2023 13:08:33 -0400 Subject: HALK HALK HALK --- src/include/lexer.h | 18 +++++++++--------- src/include/token.h | 6 +++--- src/lexer.c | 20 ++++++++++---------- src/token.c | 4 ++-- 4 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/include/lexer.h b/src/include/lexer.h index a20bf8c..e002893 100644 --- a/src/include/lexer.h +++ b/src/include/lexer.h @@ -6,15 +6,15 @@ typedef struct LEXER_STRUC { char c; // current character in content unsigned int i; // index of c char* content; // the code itself -} lexer_T; +} lexer_t; -lexer_T* lexer_init(char* content); -void lexer_next(lexer_T* lexer); -void lexer_pass(lexer_T* lexer); -token_T* lexer_get_next_token(lexer_T* lexer); -token_T* lexer_get_string(lexer_T* lexer); -token_T* lexer_get_id(lexer_T* lexer); -token_T* lexer_next_token(lexer_T* lexer, token_T* token); -char* lexer_get_c_as_string(lexer_T* lexer); +lexer_t* lexer_init(char* content); +void lexer_next(lexer_t* lexer); +void lexer_pass(lexer_t* lexer); +token_t* lexer_get_next_token(lexer_t* lexer); +token_t* lexer_get_string(lexer_t* lexer); +token_t* lexer_get_id(lexer_t* lexer); +token_t* lexer_next_token(lexer_t* lexer, token_t* token); +char* lexer_get_c_as_string(lexer_t* lexer); #endif diff --git a/src/include/token.h b/src/include/token.h index b923734..9bfc4f3 100644 --- a/src/include/token.h +++ b/src/include/token.h @@ -12,13 +12,13 @@ typedef struct TOKEN_STRUC { TOKEN_LBRAK, // '[' TOKEN_RBRAK, // ']' TOKEN_POUND, // '#'' - TOKEN_TILDE, // '~' + TOKEN_tILDE, // '~' TOKEN_QUOTE, // ''' TOKEN_EOF // '\0' } type; char* value; -} token_T; +} token_t; -token_T* token_init(int type, char* value); +token_t* token_init(int type, char* value); #endif diff --git a/src/lexer.c b/src/lexer.c index 35e9fde..24b035d 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -4,8 +4,8 @@ #include #include -lexer_T* lexer_init(char* content) { - lexer_T* lexer = calloc(1, sizeof(struct LEXER_STRUC)); +lexer_t* lexer_init(char* content) { + lexer_t* lexer = calloc(1, sizeof(struct LEXER_STRUC)); lexer->content = content; lexer->i = 0; @@ -14,7 +14,7 @@ lexer_T* lexer_init(char* content) { return lexer; } -void lexer_next(lexer_T* lexer) { +void lexer_next(lexer_t* lexer) { // if not at end of line or file if (lexer->c != '\0' && lexer->i < strlen(lexer->content)) { lexer->i += 1; // advance index 1 character @@ -22,7 +22,7 @@ void lexer_next(lexer_T* lexer) { } } -void lexer_pass(lexer_T* lexer) { +void lexer_pass(lexer_t* lexer) { while (lexer->c == ' ' || lexer->c == '\t' || lexer->c == '\n') { @@ -30,7 +30,7 @@ void lexer_pass(lexer_T* lexer) { } } -token_T* lexer_get_next_token(lexer_T* lexer) { +token_t* lexer_get_next_token(lexer_t* lexer) { while (lexer->c != '\0' && lexer->i < strlen(lexer->content)) { if (lexer->c == ' ' || lexer->c == '\t' || @@ -92,7 +92,7 @@ token_T* lexer_get_next_token(lexer_T* lexer) { case '~': return lexer_next_token( lexer, token_init( - TOKEN_TILDE, + TOKEN_tILDE, lexer_get_c_as_string(lexer) ) ); break; @@ -102,7 +102,7 @@ token_T* lexer_get_next_token(lexer_T* lexer) { return token_init(TOKEN_EOF, "\0"); } -token_T* lexer_get_string(lexer_T* lexer) { +token_t* lexer_get_string(lexer_t* lexer) { lexer_next(lexer); char* str_so_far = calloc(2, sizeof(char)); @@ -120,7 +120,7 @@ token_T* lexer_get_string(lexer_T* lexer) { return token_init(TOKEN_QUOTE, str_so_far); } -token_T* lexer_get_id(lexer_T* lexer) { +token_t* lexer_get_id(lexer_t* lexer) { char* str_so_far = calloc(1, sizeof(char)); str_so_far[0] = '\0'; @@ -135,13 +135,13 @@ token_T* lexer_get_id(lexer_T* lexer) { return token_init(TOKEN_ID, str_so_far); } -token_T* lexer_next_token(lexer_T* lexer, token_T* token) { +token_t* lexer_next_token(lexer_t* lexer, token_t* token) { lexer_next(lexer); return token; } -char* lexer_get_c_as_string(lexer_T* lexer) { +char* lexer_get_c_as_string(lexer_t* lexer) { char* str = calloc(1, sizeof(char)); str[0] = lexer->c; str[1] = '\0'; diff --git a/src/token.c b/src/token.c index da38b9a..3021a64 100644 --- a/src/token.c +++ b/src/token.c @@ -1,8 +1,8 @@ #include "include/token.h" #include -token_T* token_init(int type, char* val) { - token_T* token = calloc(1, sizeof(struct TOKEN_STRUC)); +token_t* token_init(int type, char* val) { + token_t* token = calloc(1, sizeof(struct TOKEN_STRUC)); token->type = type; token->value = val; -- cgit v1.2.3