From 13d591df4ae3dc07f3be8477f7bcbed296d7bc40 Mon Sep 17 00:00:00 2001 From: Lorenzo Torres Date: Tue, 9 Jun 2026 08:45:29 +0200 Subject: feat: first commit --- lexer.h | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 lexer.h (limited to 'lexer.h') diff --git a/lexer.h b/lexer.h new file mode 100644 index 0000000..6ebdb01 --- /dev/null +++ b/lexer.h @@ -0,0 +1,93 @@ +#ifndef LEXER_H +#define LEXER_H + +#include +#include + +typedef enum { + TOKEN_HEAD, + + TOKEN_IDENTIFIER, + TOKEN_INTEGER, + TOKEN_FLOAT, + TOKEN_STRING, + TOKEN_CHAR, + + TOKEN_TRUE, + TOKEN_FALSE, + + TOKEN_IF, + TOKEN_ELSE, + TOKEN_WHILE, + TOKEN_FOR, + TOKEN_BREAK, + TOKEN_CASE, + TOKEN_CONST, + TOKEN_DO, + TOKEN_ENUM, + TOKEN_EXTERN, + TOKEN_GOTO, + TOKEN_INLINE, + TOKEN_RETURN, + TOKEN_SIGNED, + TOKEN_UNSIGNED, + TOKEN_STATIC, + TOKEN_STRUCT, + TOKEN_SWITCH, + TOKEN_TYPEDEF, + TOKEN_UNION, + TOKEN_VOLATILE, + + TOKEN_COLON, + TOKEN_SEMICOLON, + TOKEN_COMMA, + TOKEN_DOT, + TOKEN_ARROW, + TOKEN_ASSIGN, + TOKEN_EQUAL, + TOKEN_LSHIFT, + TOKEN_RSHIFT, + TOKEN_LSHIFT_EQ, + TOKEN_RSHIFT_EQ, + TOKEN_XOR, + TOKEN_XOR_EQ, + TOKEN_OR, + TOKEN_BOR, + TOKEN_BOR_EQ, + TOKEN_NOT, + TOKEN_NOT_EQ, + TOKEN_GREATER, + TOKEN_GREATER_EQ, + TOKEN_LESS, + TOKEN_LESS_EQ, + TOKEN_LPAREN, + TOKEN_RPAREN, + TOKEN_LSQUARE, + TOKEN_RSQUARE, + TOKEN_LCURLY, + TOKEN_RCURLY, + TOKEN_PLUS, + TOKEN_MINUS, + TOKEN_STAR, + TOKEN_SLASH, + TOKEN_PLUS_EQ, + TOKEN_PLUS_PLUS, + TOKEN_MINUS_EQ, + TOKEN_MINUS_MINUS, + TOKEN_STAR_EQ, + TOKEN_SLASH_EQ, + TOKEN_REF, +} token_type; + +typedef struct _token { + char *lexeme; + size_t length; + token_type type; + + struct _token *next; + struct _token *prev; +} token; + +token *lexer_parse(char *src); + +#endif -- cgit v1.2.3