parsing et execution partielle de hugo

This commit is contained in:
hugogogo
2021-11-02 13:38:52 +01:00
parent 698dcbe1ed
commit a926a817da
7 changed files with 78 additions and 339 deletions

View File

@@ -1,6 +1,35 @@
#include "minishell.h"
size_t count_pipes(t_token *token);
t_cmd **create_cmd(t_token *token_list, size_t cmd_nbr);
void handle_argv(t_token *token, t_cmd **cmd, size_t cmd_nbr);
void handle_path(t_cmd **cmd_arr, char **envp);
void handle_fd(t_token *token, t_cmd **cmd_arr);
void fd_heredoc(t_token *token, t_cmd *cmd);
void fd_redirection(t_token *token, t_cmd *cmd);
void find_path(char **argv, char **envp);
int handle_builtin(t_cmd *cmd);
int fill_builtin(t_cmd *cmd, int (*builtin)(int, char **, t_all *));
int next_cmd(t_token *token);
int is_redirection(enum e_token_id id);
t_cmd **parsing(t_token *token_list, char **envp)
{
t_cmd **cmd_arr;
size_t cmd_nbr;
if (!valid_syntax(token_list))
return (NULL);
cmd_nbr = count_pipes(token_list);
cmd_arr = create_cmd(token_list, cmd_nbr);
// cmd_expansion(cmd_arr, envp);
handle_argv(token_list, cmd_arr, cmd_nbr);
handle_path(cmd_arr, envp);
handle_fd(token_list, cmd_arr);
return (cmd_arr);
}
size_t count_pipes(t_token *token)
{
size_t nb;
@@ -186,12 +215,6 @@ void fd_heredoc(t_token *token, t_cmd *cmd)
{
(void)token;
(void)cmd;
// if (token->id == T_DGREAT) // <<
// {
// cmd->fd_out = open(token->next->content, O_WRONLY | O_TMPFILE | O_APPEND, S_IRWXU);
// token->out = T_TOKEN;
// token->next->id = T_TOKEN;
// }
}
void handle_fd(t_token *token, t_cmd **cmd_arr)
@@ -226,31 +249,6 @@ void handle_fd(t_token *token, t_cmd **cmd_arr)
}
}
t_cmd **parsing(t_token *token_list, char **envp)
{
t_cmd **cmd_arr;
size_t cmd_nbr;
if (!valid_syntax(token_list))
return (NULL);
cmd_nbr = count_pipes(token_list);
cmd_arr = create_cmd(token_list, cmd_nbr);
// cmd_expansion(cmd_arr, envp);
handle_argv(token_list, cmd_arr, cmd_nbr);
handle_path(cmd_arr, envp);
handle_fd(token_list, cmd_arr);
//int j;
//j = 0;
//while (cmd_arr[j])
//{
// printf("%i\n", j);
// print_matrix(cmd_arr[j]->argv, " ; ");
// j++;
//}
return (cmd_arr);
}
/* -------------------------------------------------------
The grammar symbols