From 7a361c2e7385c2e670a0e2cc8d9092814ea17253 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Fri, 13 Mar 2026 01:05:34 -0400 Subject: not even compiled once but we ball --- lexer.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 lexer.h (limited to 'lexer.h') diff --git a/lexer.h b/lexer.h new file mode 100644 index 0000000..62ee9c2 --- /dev/null +++ b/lexer.h @@ -0,0 +1,72 @@ +#ifndef LEXER_H +#define LEXER_H + +enum token_type { + IDENTIFIER, + INT_LIT, + CHAR_LIT, + STR_LIT, + HASHTAG, + LPAREN, + RPAREN, + LCURLY, + RCURLY, + LSQUARE, + RSQUARE, + COLON, + SEMI, + COMMA, + DOT, + QMARK, + NOT, + NEQ, + XOR, + XEQ, + AMP, + LOG_AND, + AND_EQ, + STAR, + MUL_EQ, + NEG, + NEG_EQ, + ARROW, + ASSIGN, + TEST_EQ, + PLUS, + PLUS_EQ, + BSLASH, + PIPE, + LOG_PIPE, + PIPE_EQ, + DIV, + DIV_EQ, // comments too + LT, + GT, + LEQ, + GEQ, + SHR, + SHR_EQ, + SHL, + SHL_EQ + /* more to come */ + // ->, everything that can precede = (multi-symbols) +}; + +typedef unsigned long long intlit_t; + +struct token { + enum token_type type; + union { + char* identifier; + intlit_t int_lit; + char char_lit; + char* str_lit; + void* unused; + } data; +}; + +void lexer_load(const char* path); +bool lexer_peek(struct token* p_token); +bool lexer_pop(struct token* p_token); + +#endif -- cgit v1.2.3