33 lines
617 B
C
33 lines
617 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, // + or -
|
|
TOKEN_FACTOR, // * or /
|
|
TOKEN_EQUAL, // =
|
|
TOKEN_END // null (end of input)
|
|
} token_type;
|
|
|
|
typedef struct
|
|
{
|
|
token_type type;
|
|
union
|
|
{
|
|
char value_char;
|
|
int value_int;
|
|
double value_double;
|
|
};
|
|
} token;
|
|
|
|
int lexerize(const char *input, token *tokens);
|
|
|
|
#endif |