diff options
| author | Christopher Uhlig | 2025-01-13 11:06:54 +0100 |
|---|---|---|
| committer | Christopher Uhlig | 2025-01-13 11:06:54 +0100 |
| commit | 78dc50a2bce3c6e31405437189e2990d8fc720ac (patch) | |
| tree | d61d9f0d279e191c1bfb34929908f412cf58c02d /src/repl.c | |
| parent | ae5512ea0d6d8be833ca3a9b39f93239109f45b4 (diff) | |
| download | minishell-78dc50a2bce3c6e31405437189e2990d8fc720ac.tar.gz minishell-78dc50a2bce3c6e31405437189e2990d8fc720ac.zip | |
here
Diffstat (limited to 'src/repl.c')
| -rw-r--r-- | src/repl.c | 30 |
1 files changed, 27 insertions, 3 deletions
@@ -6,14 +6,34 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/24 16:07:04 by dkaiser #+# #+# */ -/* Updated: 2024/09/13 16:26:35 by dkaiser ### ########.fr */ +/* Updated: 2025/01/11 16:01:44 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ #include "../include/minishell.h" #include "token.h" -void repl(const char *prompt) +t_token *reverse_token_list(t_token *head) +{ + t_token *prev; + t_token *current; + t_token *next; + + prev = NULL; + current = head; + next = NULL; + while (current != NULL) + { + next = current->previous; + current->next = prev; + current->previous = next; + prev = current; + current = next; + } + return (prev); +} + +void repl(const char *prompt, t_env **env) { char *input; t_token *token_list; @@ -29,9 +49,13 @@ void repl(const char *prompt) add_history(input); token_list = NULL; tokenizer(input, &token_list, '\0'); - lines = parse(token_list); + token_list = reverse_token_list(token_list); + lines = parse(token_list, env); if (lines) + { print_ast(lines->content); + eval(lines->content, env); + } free(input); } } |
