split files
This commit is contained in:
@@ -1,37 +1,6 @@
|
||||
#ifndef COMPUTORV1_H
|
||||
#define COMPUTORV1_H
|
||||
|
||||
#include "../libft/includes/libft.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ERROR_BASIC, // 0
|
||||
ERROR_UNKNOWN_TOKEN, // 1
|
||||
} program_error;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TOKEN_PLUS, // +
|
||||
TOKEN_MINUS, // -
|
||||
TOKEN_VARIABLE, // x, y, etc.
|
||||
TOKEN_NUMBER, // int or double
|
||||
TOKEN_POWER, // ^ or **
|
||||
TOKEN_MULTIPLICATION, // *
|
||||
TOKEN_DIVISION, // /
|
||||
TOKEN_END // null (end of input)
|
||||
} TokenType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TokenType type;
|
||||
union
|
||||
{
|
||||
double num_value; // For NUMBER
|
||||
char var_value; // For VARIABLE (single char, e.g., 'x')
|
||||
};
|
||||
} t_token;
|
||||
|
||||
#define MAX_TOKENS 100
|
||||
t_token tokens[MAX_TOKENS];
|
||||
#include "libft.h"
|
||||
|
||||
#endif
|
||||
14
headers/errors.h
Normal file
14
headers/errors.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef ERRORS_H
|
||||
#define ERRORS_H
|
||||
|
||||
#include "../libft/includes/libft.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ERROR_BASIC = 0,
|
||||
ERROR_UNKNOWN_TOKEN = -1,
|
||||
} program_error;
|
||||
|
||||
int stop_errors(int err);
|
||||
|
||||
#endif
|
||||
31
headers/lexer.h
Normal file
31
headers/lexer.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef LEXER_H
|
||||
#define LEXER_H
|
||||
|
||||
#include "../libft/includes/libft.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TOKEN_PLUS, // +
|
||||
TOKEN_MINUS, // -
|
||||
TOKEN_VARIABLE, // x, y, etc.
|
||||
TOKEN_NUMBER, // int or double
|
||||
TOKEN_POWER, // ^ or **
|
||||
TOKEN_MULTIPLICATION, // *
|
||||
TOKEN_DIVISION, // /
|
||||
TOKEN_END // null (end of input)
|
||||
} token_type;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
token_type type;
|
||||
union
|
||||
{
|
||||
double num_value; // For NUMBER
|
||||
char var_value; // For VARIABLE (single char, e.g., 'x')
|
||||
};
|
||||
} token;
|
||||
|
||||
#define MAX_TOKENS 100
|
||||
int lexerize(const char *input, token tokens[MAX_TOKENS]);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user