update: parser now uses tokens from lexer

fixes pending:
 - some functions are longer than norminette allows
 - find solution to a list of commands being returned, even though a
syntax error is found when processing tokens (maybe delegate some work
to the lexer and return only a syntax-valid list?)
This commit is contained in:
2026-02-11 02:51:30 +01:00
parent 1715f2dd40
commit c493979a18
7 changed files with 475 additions and 289 deletions

View File

@@ -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
@@ -54,6 +82,12 @@ typedef struct s_minishell
bool exit;
} t_minishell;
typedef struct s_redirection
{
t_token_type type;
char *target;
} t_redirection;
/**
* @brief Structure representing a single command in the shell
*
@@ -70,6 +104,7 @@ typedef struct s_command
char **argv;
char *path;
t_list *redirections;
t_list *heredocs;
} t_command;
/**