From 711eb1d91832267bdd1fe2bc57eeebba9e637c52 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Wed, 20 Nov 2024 21:11:38 -0800 Subject: init --- src/lexer.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/lexer.h (limited to 'src/lexer.h') 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 -- cgit v1.2.3-70-g09d2