feat: include command parsing in minishell struct

This commit is contained in:
Quinten Mennen 2025-02-11 16:35:32 +01:00
parent 0992ae20cf
commit 3dda5621b6
4 changed files with 6 additions and 4 deletions

View File

@ -59,5 +59,6 @@ typedef struct s_minishell
char *line;
t_lexer *lexer;
t_list *tokens;
t_list *commands;
} t_minishell;
#endif // TYPEDEF_H

View File

@ -15,7 +15,6 @@
int main(int argc, char **argv, char **envp)
{
t_minishell *minishell;
t_list *commands;
(void)argc;
(void)argv;
@ -28,11 +27,10 @@ int main(int argc, char **argv, char **envp)
minishell->line = ft_prompt(minishell);
minishell->lexer = ft_lexer_new(minishell->line);
minishell->tokens = ft_parse_input(minishell->lexer);
commands = parser_get_commands(minishell->tokens);
simple_builtins(minishell);
minishell->commands = parser_get_commands(minishell->tokens);
//ft_lstiter(minishell->tokens, print_list);
free_minishell_line(minishell);
ft_lstclear(&commands, free_command_list);
ft_lstclear(&minishell->commands, free_command_list);
}
free_minishell(minishell);
return (EXIT_SUCCESS);

View File

@ -20,4 +20,6 @@ void free_minishell_line(t_minishell *minishell)
ft_lexer_free(minishell->lexer);
if (minishell->tokens)
ft_lstclear(&minishell->tokens, ft_clear_tokenlist);
if (minishell->commands)
ft_lstclear(&minishell->commands, free_command_list);
}

View File

@ -26,5 +26,6 @@ t_minishell *init_minishell(void)
minishell->line = NULL;
minishell->lexer = NULL;
minishell->tokens = NULL;
minishell->commands = NULL;
return (minishell);
}