minishell/inc/minishell.h

81 lines
1.9 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
typedef struct s_minishell
{
t_enviroment *enviroment;
char *pwd;
} t_minishell;
typedef enum
{
T_WORD,
T_PIPE,
T_REDIRECT_IN,
T_REDIRECT_OUT,
T_APPEND_OUT,
T_EOF,
T_ERROR
} TokenType;
typedef struct s_token
{
TokenType 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(TokenType 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