Files
42_EXT_05_computorv1/headers/lexer.h
2026-05-03 00:20:39 +02:00

43 lines
767 B
C

#ifndef LEXER_H
#define LEXER_H
#include "libft.h"
#include "errors.h"
#include <stdbool.h>
typedef enum
{
TOKEN_VARIABLE, // x, y, etc.
TOKEN_NUMBER_INT, // int
TOKEN_NUMBER_DOUBLE, // double
TOKEN_POWER, // ^ or **
TOKEN_SIGN_PLUS, // +
TOKEN_SIGN_MINUS, // -
TOKEN_FACTOR_MULT, // *
TOKEN_FACTOR_DIV, // / or :
TOKEN_EQUAL, // =
TOKEN_END // null (end of input)
} token_type;
typedef enum
{
TOKEN_NO_TAG,
TOKEN_NUMBER,
TOKEN_SIGN,
TOKEN_FACTOR,
} token_tag;
typedef struct
{
token_type type;
token_tag tag;
union
{
char value_char;
double value_double;
};
} token;
int lexerize(const char *input, token *tokens);
#endif