lexer complete with luke memory solution
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user