diff options
author | Kai Stevenson <kai@kaistevenson.com> | 2024-11-20 21:11:38 -0800 |
---|---|---|
committer | Kai Stevenson <kai@kaistevenson.com> | 2024-11-20 21:11:38 -0800 |
commit | 711eb1d91832267bdd1fe2bc57eeebba9e637c52 (patch) | |
tree | 6cbd10ee276f1cb8119d2528cc1f7a04894228de /src/lexer.h |
Diffstat (limited to 'src/lexer.h')
-rw-r--r-- | src/lexer.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/lexer.h b/src/lexer.h new file mode 100644 index 0000000..52d00fa --- /dev/null +++ b/src/lexer.h @@ -0,0 +1,49 @@ +#ifndef LEXER +#define LEXER +typedef enum TokenType { + ERR, + EOL, + NAME, + KEYWORD, + STRING_LIT, + INT_LIT, + SEMICOLON, + OPEN_PAREN, + CLOSE_PAREN, + OPEN_BRACE, + CLOSE_BRACE, + OPEN_BRACKET, + CLOSE_BRACKET, + START_COMMENT, + EQUALS, + DOUBLE_EQUALS, + NEGATION, + ASTERISK, + PLUS_SIGN, + FUNCTION +} tokenType_t; +typedef enum Keyword { + K_NONE, + K_VOID, + K_INT, + K_FLOAT, + K_STRING +} keyword_t; +typedef struct Token { + tokenType_t type; + void* value; +} token_t; +token_t init_token(tokenType_t type, void* value); +typedef struct TokenSet { + token_t* tokens; + int count; +} tokenSet_t; +tokenSet_t init_tokenset(token_t* tokens, int count); +char* tttos(tokenType_t tokenType); +int advance_whitespace(char** linePointer); +keyword_t try_get_keyword(char* name); +char keyword_is_type(keyword_t keyword); +token_t lex_first_token(char** content); +token_t lex_first_string(char** content); +token_t lex_first_int(char** content); +#endif |