summaryrefslogtreecommitdiff
path: root/src/lexer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexer.h')
-rw-r--r--src/lexer.h49
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