summaryrefslogtreecommitdiff
path: root/lexer.h
diff options
context:
space:
mode:
authorCarson Fleming <[email protected]>2026-03-13 01:05:34 -0400
committerCarson Fleming <[email protected]>2026-03-13 01:05:34 -0400
commit7a361c2e7385c2e670a0e2cc8d9092814ea17253 (patch)
tree4573177a388412a2e7bc1b39df2e8569e7f9316e /lexer.h
downloadccc-7a361c2e7385c2e670a0e2cc8d9092814ea17253.tar.gz
not even compiled once but we ball
Diffstat (limited to 'lexer.h')
-rw-r--r--lexer.h72
1 files changed, 72 insertions, 0 deletions
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