86 lines
2.1 KiB
C
86 lines
2.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* :::::::: */
|
|
/* minishell.h :+: :+: */
|
|
/* +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
|
/* +#+ */
|
|
/* Created: 2025/02/04 16:13:13 by whaffman #+# #+# */
|
|
/* Updated: 2025/02/04 18:58:01 by whaffman ######## odam.nl */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#ifndef MINISHELL_H
|
|
# define MINISHELL_H
|
|
|
|
# include "allowed.h"
|
|
# include "libft.h"
|
|
# include "enviroment.h"
|
|
# include "prompt.h"
|
|
|
|
# define TRUE 1
|
|
# define FALSE 0
|
|
|
|
# define SUCCESS 1
|
|
# define FAILURE 0
|
|
|
|
# define RED "\033[0;31m"
|
|
# define GREEN "\033[0;32m"
|
|
# define YELLOW "\033[0;33m"
|
|
# define BLUE "\033[0;34m"
|
|
# define MAGENTA "\033[0;35m"
|
|
# define CYAN "\033[0;36m"
|
|
# define RESET "\033[0m"
|
|
|
|
typedef struct s_minishell
|
|
{
|
|
t_enviroment *enviroment;
|
|
|
|
} t_minishell;
|
|
|
|
typedef enum
|
|
{
|
|
T_WORD,
|
|
T_PIPE,
|
|
T_REDIRECT_IN,
|
|
T_REDIRECT_OUT,
|
|
T_APPEND_OUT,
|
|
T_EOF,
|
|
T_ERROR
|
|
} t_token_type;
|
|
|
|
typedef struct s_token
|
|
{
|
|
t_token_type type;
|
|
char *value;
|
|
int position;
|
|
} t_token;
|
|
|
|
typedef struct s_lexer
|
|
{
|
|
char *input;
|
|
int pos;
|
|
int n_pos;
|
|
char current_char;
|
|
} t_lexer;
|
|
|
|
int ft_isspace(const char c);
|
|
|
|
/**
|
|
* Lexer
|
|
*/
|
|
t_lexer *ft_lexer_new(const char *input);
|
|
void ft_lexer_free(t_lexer *lexer);
|
|
void ft_lexer_readchar(t_lexer *lexer);
|
|
char *ft_lexer_readword(t_lexer *lexer);
|
|
t_list *ft_parse_input(t_lexer *lexer);
|
|
/**
|
|
* Token
|
|
*/
|
|
t_token *ft_token_next(t_lexer *lexer);
|
|
t_token *ft_token_new(t_token_type type, char *c, int pos);
|
|
void ft_token_free(t_token *token);
|
|
void ft_clear_tokenlist(void *content);
|
|
t_token *ft_parse_token(t_lexer *lexer);
|
|
#endif
|