Merge branch 'solo' into feature/executor-gl
# Conflicts: # src/parser/parser.c
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/22 19:10:13 by sede-san #+# #+# */
|
||||
/* Updated: 2026/02/09 18:45:41 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/10 23:21:35 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -19,9 +19,37 @@
|
||||
/* Structures & Data Types */
|
||||
/******************************************************************************/
|
||||
|
||||
typedef struct s_minishell t_minishell;
|
||||
typedef struct s_variables t_variables;
|
||||
typedef struct s_command t_command;
|
||||
# define TOKENS_COUNT 5
|
||||
|
||||
typedef enum e_token_type
|
||||
{
|
||||
TOKEN_WORD,
|
||||
TOKEN_PIPE,
|
||||
TOKEN_REDIRECT_IN,
|
||||
TOKEN_REDIRECT_OUT,
|
||||
TOKEN_APPEND,
|
||||
TOKEN_HEREDOC
|
||||
} t_token_type;
|
||||
|
||||
typedef struct s_token
|
||||
{
|
||||
t_token_type type;
|
||||
char *value;
|
||||
} t_token;
|
||||
|
||||
typedef enum e_redirection_type
|
||||
{
|
||||
REDIRECT_IN,
|
||||
REDIRECT_OUT,
|
||||
APPEND,
|
||||
HEREDOC
|
||||
} t_redirection_type;
|
||||
|
||||
typedef struct s_redirection
|
||||
{
|
||||
t_token_type type;
|
||||
char *target;
|
||||
} t_redirection;
|
||||
|
||||
/**
|
||||
* @brief Structure that holds both environment and internal variables
|
||||
@@ -70,6 +98,7 @@ typedef struct s_command
|
||||
char **argv;
|
||||
char *path;
|
||||
t_list *redirections;
|
||||
t_list *heredocs;
|
||||
} t_command;
|
||||
|
||||
/**
|
||||
|
||||
23
include/errors.h
Normal file
23
include/errors.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* errors.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/02/10 22:28:01 by sede-san #+# #+# */
|
||||
/* Updated: 2026/02/10 23:24:16 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ERRORS_H
|
||||
# define ERRORS_H
|
||||
|
||||
# include "minishell.h"
|
||||
# include "core.h"
|
||||
# include "parser.h"
|
||||
|
||||
extern void syntax_error_unexpected_token(t_token *token);
|
||||
extern void malloc_error(void);
|
||||
|
||||
#endif /* ERRORS_H */
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/20 16:35:10 by sede-san #+# #+# */
|
||||
/* Updated: 2026/02/09 18:38:16 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/10 22:12:58 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# include "chardefs.h"
|
||||
# include <stdbool.h>
|
||||
# include <stdint.h>
|
||||
# include <errno.h>
|
||||
# include <readline/readline.h> // readline(3), rl_clear_history(),
|
||||
// rl_on_new_line(), rl_replace_line(),
|
||||
// rl_redisplay()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/22 19:03:51 by sede-san #+# #+# */
|
||||
/* Updated: 2026/02/09 21:19:02 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/12 03:06:43 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -17,38 +17,6 @@
|
||||
# include "core.h"
|
||||
# include "builtins.h"
|
||||
|
||||
# define TOKENS_COUNT 5
|
||||
|
||||
typedef enum e_token_type
|
||||
{
|
||||
TOKEN_WORD,
|
||||
TOKEN_PIPE,
|
||||
TOKEN_REDIRECT_IN,
|
||||
TOKEN_REDIRECT_OUT,
|
||||
TOKEN_APPEND,
|
||||
TOKEN_HEREDOC
|
||||
} t_token_type;
|
||||
|
||||
typedef struct s_token
|
||||
{
|
||||
t_token_type type;
|
||||
char *value;
|
||||
} t_token;
|
||||
|
||||
typedef enum e_redirection_type
|
||||
{
|
||||
REDIRECT_IN,
|
||||
REDIRECT_OUT,
|
||||
APPEND,
|
||||
HEREDOC
|
||||
} t_redirection_type;
|
||||
|
||||
typedef struct s_redirection
|
||||
{
|
||||
t_redirection_type type;
|
||||
char *target;
|
||||
} t_redirection;
|
||||
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
/******************************************************************************/
|
||||
@@ -57,4 +25,16 @@ typedef struct s_redirection
|
||||
|
||||
extern t_list *parse(char *line, t_minishell *minishell);
|
||||
|
||||
// lexer.c
|
||||
|
||||
extern t_list *lex(const char *line);
|
||||
|
||||
extern void token_clear(t_token *token);
|
||||
extern t_command *command_new(t_list **tokens);
|
||||
extern void command_clear(t_command *command);
|
||||
extern void command_add_tokens(t_command **command, t_list **tokens);
|
||||
extern bool is_pipe(t_token *token);
|
||||
extern bool is_redirection(t_token *token);
|
||||
void redirection_add(t_list **tokens, t_token *token, t_command **command);
|
||||
void words_add(t_list **tokens, t_command **command);
|
||||
#endif /* PARSER_H */
|
||||
|
||||
Reference in New Issue
Block a user