lexer complete with luke memory solution

This commit is contained in:
hugogogo
2026-04-29 12:41:19 +02:00
parent 9ced220c00
commit 26fa8025ef
3 changed files with 134 additions and 45 deletions

View File

@@ -6,7 +6,8 @@
typedef enum
{
TOKEN_VARIABLE, // x, y, etc.
TOKEN_NUMBER, // int or double
TOKEN_NUMBER_INT, // int
TOKEN_NUMBER_DOUBLE, // double
TOKEN_POWER, // ^ or **
TOKEN_PLUS, // +
TOKEN_MINUS, // -
@@ -20,12 +21,12 @@ typedef struct
token_type type;
union
{
double num_value; // For NUMBER
char var_value; // For VARIABLE (single char, e.g., 'x')
char value_char;
int value_int;
double value_double;
};
} token;
#define MAX_TOKENS 100
int lexerize(const char *input, token tokens[MAX_TOKENS]);
void lexerize(const char *input, token *tokens);
#endif