aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--include/env.h11
-rw-r--r--include/minishell.h10
-rw-r--r--src/builtins_part_one.c152
-rw-r--r--src/builtins_part_two.c82
-rw-r--r--src/env.c20
-rw-r--r--src/env_to_strlst.c58
-rw-r--r--src/execute_cmd.c76
-rw-r--r--src/get_cmd_path.c82
-rw-r--r--src/interpreter.c90
-rw-r--r--src/main.c13
-rw-r--r--src/new_token.c29
-rw-r--r--src/repl.c7
-rw-r--r--src/tokenizer.c2
14 files changed, 616 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 827c317..7828678 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,8 @@ HEADERS = -I include -I $(LIB_DIR)/libft
VPATH := src
SRC := main.c debug_tools.c init.c signal_handling.c repl.c new_token.c \
free_token.c new_node.c free_node.c tokenizer.c parser.c \
- parse_cmd.c collect_redirs.c print_ast.c
+ parse_cmd.c collect_redirs.c print_ast.c interpreter.c env.c \
+ get_cmd_path.c env_to_strlst.c execute_cmd.c
OBJ_DIR := _obj
OBJ := $(addprefix $(OBJ_DIR)/, $(SRC:%.c=%.o))
diff --git a/include/env.h b/include/env.h
index 5a65333..a35bec3 100644
--- a/include/env.h
+++ b/include/env.h
@@ -6,10 +6,12 @@
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/08 16:53:39 by dkaiser #+# #+# */
-/* Updated: 2024/10/17 15:37:32 by chuhlig ### ########.fr */
+/* Updated: 2024/10/25 19:53:38 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
+#include "libft.h"
+
typedef struct s_env
{
char *name;
@@ -17,6 +19,7 @@ typedef struct s_env
struct s_env *next;
} t_env;
-void getenvlst(t_env **env, char **en);
-void free_envlst(t_env **env);
-
+void getenvlst(t_env **env, char **en);
+void free_envlst(t_env **env);
+char *env_get(t_env *env, char *name);
+char **env_to_strlst(t_env *env); \ No newline at end of file
diff --git a/include/minishell.h b/include/minishell.h
index 6997b15..b2a3845 100644
--- a/include/minishell.h
+++ b/include/minishell.h
@@ -3,10 +3,10 @@
/* ::: :::::::: */
/* minishell.h :+: :+: :+: */
/* +:+ +:+ +:+ */
-/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/22 17:14:49 by dkaiser #+# #+# */
-/* Updated: 2024/08/11 12:22:07 by dkaiser ### ########.fr */
+/* Updated: 2024/10/25 16:10:21 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
@@ -29,11 +29,15 @@
int init(void);
int init_signal_handling(void);
-void repl(const char *prompt);
+void repl(const char *prompt, t_env **env);
t_list *parse(t_token *tokens);
t_node *parse_cmd(t_token *tokens);
t_redirection *collect_redirs(t_token **tokens);
void print_ast(t_node *ast);
+
+int eval(t_node *node, t_env **env);
+char *get_cmd_path(char *cmd, t_env *env);
+int execute_cmd(t_cmd *cmd, t_env *env);
#endif
diff --git a/src/builtins_part_one.c b/src/builtins_part_one.c
new file mode 100644
index 0000000..6b92d9c
--- /dev/null
+++ b/src/builtins_part_one.c
@@ -0,0 +1,152 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* builtins_part_one.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/08/09 17:01:16 by chuhlig #+# #+# */
+/* Updated: 2024/10/25 20:52:36 by chuhlig ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "env.h"
+
+int echo(char **av)
+{
+ int i;
+ int f;
+
+ i = 1;
+ f = 1;
+ if (av[1][0] == '\0')
+ {
+ write(1, "\n", 1);
+ return (1);
+ }
+ if (ft_strcmp(av[1], "-n"))
+ {
+ i++;
+ f = 0;
+ }
+ while (av[i])
+ {
+ write(1, &av[1], ft_strlen(av[i]));
+ i++;
+ }
+ if (f)
+ write(1, "\n", 1);
+ return (0);
+}
+
+int pwd(t_env **env, char *av)
+{
+ t_env *current;
+ t_env *prev;
+ char *tmp;
+
+ current = env;
+ prev = NULL;
+ while (current)
+ {
+ if (ft_strcmp(current->name, av == 0))
+ break ;
+ prev = current;
+ current = current->next;
+ }
+ ft_printf("%s\n", current->value);
+ return (0);
+}
+
+int env(t_env **env)
+{
+ t_env *current;
+ t_env *prev;
+
+ current = env;
+ prev = NULL;
+ while (current)
+ {
+ ft_printf("%s", current->name);
+ ft_printf("=%s\n", current->value);
+ prev = current;
+ current = current->next;
+ }
+ return (0);
+}
+
+int exit(char *av)
+{
+ freenode free toke free sequence stop repl free env;
+ clear history;
+}
+
+int export(char **av, t_env **env)
+{
+ char *tmp;
+ t_env *current;
+ int i;
+
+ i = i;
+ while (av[i])
+ {
+ if (t_strchr(av[i], '='))
+ {
+ tmp = ft_strchr(av[i], '=');
+ tmp = '\0';
+ current = *env;
+ while (current)
+ {
+ if (ft_strcmp(current->name, tmp[i]) == 0)
+ {
+ free(current->value);
+ current->value = ft_strdup(tmp + 1);
+ break ;
+ }
+ current = current->next;
+ }
+ if (!current)
+ {
+ current = malloc(sizeof(t_env));
+ current->name = ft_strdup(av[i]);
+ current->value = ft_strdup(tmp + 1);
+ current->next = *env;
+ *env = current;
+ }
+ }
+ i++;
+ }
+ return (1);
+}
+
+int unset(char **av, t_env **env)
+{
+ t_env *current;
+ t_env *prev;
+ int i;
+
+ i = 0;
+ current = env;
+ prev = NULL;
+ while (av[i])
+ {
+ while (current)
+ {
+ if (ft_strcmp(current->name, av[i] == 0))
+ break ;
+ prev = current;
+ current = current->next;
+ }
+ if (current)
+ {
+ if (prev)
+ prev->next = current->next;
+ else
+ *env = current->next;
+ free(current->value);
+ free(current);
+ }
+ i++;
+ }
+ return (0);
+} \ No newline at end of file
diff --git a/src/builtins_part_two.c b/src/builtins_part_two.c
new file mode 100644
index 0000000..94ef258
--- /dev/null
+++ b/src/builtins_part_two.c
@@ -0,0 +1,82 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* builtins_part_two.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/10/25 20:52:16 by chuhlig #+# #+# */
+/* Updated: 2024/10/25 20:52:46 by chuhlig ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "env.h"
+
+void update_oldpwd(t_env **env)
+{
+ t_env *current;
+ t_env *prev;
+ char cwd[1028];
+ char *tmp;
+
+ while (current)
+ {
+ if (ft_strncmp(current->name, "OLDPWD", 6) == 0)
+ break ;
+ prev = current;
+ current = current->next;
+ }
+ getcwd(cwd, sizeof(cwd));
+ tmp = ft_strdup(cwd);
+ free(current->value);
+ current->value = tmp;
+}
+
+void update_pwd(t_env **env)
+{
+ t_env *current;
+ t_env *prev;
+ char cwd[1028];
+ char *tmp;
+
+ while (current)
+ {
+ if (ft_strncmp(current->name, "PWD", 3) == 0)
+ break ;
+ prev = current;
+ current = current->next;
+ }
+ getcwd(cwd, sizeof(cwd));
+ tmp = ft_strdup(cwd);
+ free(current->value);
+ current->value = tmp;
+}
+
+int cd(t_env **env, char **av)
+{
+ t_env *current;
+ t_env *prev;
+ t_env *pwd;
+
+ current = env;
+ if (av[1] == NULL)
+ {
+ update_oldpwd(&env);
+ while (current)
+ {
+ if (ft_strncmp(current->name, "HOME", 4) == 0)
+ break ;
+ prev = current;
+ current = current->next;
+ }
+ if (chdir(current->value) == -1)
+ return ;
+ }
+ else
+ {
+ update_oldpwd(&env);
+ if (chdir(av[1]) == -1)
+ return ;
+ update_pwd(&env);
+ }
+} \ No newline at end of file
diff --git a/src/env.c b/src/env.c
index 8105bf4..3110965 100644
--- a/src/env.c
+++ b/src/env.c
@@ -6,11 +6,14 @@
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/17 14:31:07 by chuhlig #+# #+# */
-/* Updated: 2024/10/17 15:18:44 by chuhlig ### ########.fr */
+/* Updated: 2024/10/25 19:17:54 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
#include "env.h"
+#include "get_next_line.h"
+#include "libft.h"
+#include <stdlib.h>
void getenvlst(t_env **env, char **en)
{
@@ -22,7 +25,7 @@ void getenvlst(t_env **env, char **en)
while (en[i] != NULL)
{
tmp = ft_strchr(en[i], '=');
- tmp = '\0';
+ *tmp = '\0';
current = *env;
current = malloc(sizeof(t_env));
current->name = ft_strdup(en[i]);
@@ -47,4 +50,15 @@ void free_envlst(t_env **env)
free(cur);
cur = new;
}
-} \ No newline at end of file
+}
+
+char *env_get(t_env *env, char *name)
+{
+ while (env != NULL)
+ {
+ if (!ft_strncmp(env->name, name, ft_strlen(name)))
+ return (env->value);
+ env = env->next;
+ }
+ return (NULL);
+}
diff --git a/src/env_to_strlst.c b/src/env_to_strlst.c
new file mode 100644
index 0000000..3a58df9
--- /dev/null
+++ b/src/env_to_strlst.c
@@ -0,0 +1,58 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* env_to_strlst.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/10/21 14:52:08 by dkaiser #+# #+# */
+/* Updated: 2024/10/21 15:07:33 by dkaiser ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include "minishell.h"
+
+static char *get_var_assign(t_env *cur);
+
+char **env_to_strlst(t_env *env)
+{
+ int size;
+ t_env *cur;
+ char **result;
+ int i;
+
+ size = 0;
+ cur = env;
+ while (cur != NULL)
+ {
+ size++;
+ cur = cur->next;
+ }
+ result = malloc(sizeof(char *) * (size + 1));
+ if (result == NULL)
+ return (NULL);
+ i = 0;
+ cur = env;
+ while (i < size)
+ {
+ result[i] = get_var_assign(cur);
+ cur = cur->next;
+ i++;
+ }
+ result[i] = NULL;
+ return (result);
+}
+
+static char *get_var_assign(t_env *cur)
+{
+ char *left_side;
+ char *result;
+
+ left_side = ft_strjoin(cur->name, "=");
+ if (left_side == NULL)
+ return (NULL);
+ result = ft_strjoin(left_side, cur->value);
+ free(left_side);
+ return (result);
+}
diff --git a/src/execute_cmd.c b/src/execute_cmd.c
new file mode 100644
index 0000000..6386fc0
--- /dev/null
+++ b/src/execute_cmd.c
@@ -0,0 +1,76 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* execute_cmd.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/10/21 13:58:56 by dkaiser #+# #+# */
+/* Updated: 2024/10/25 20:59:22 by chuhlig ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "minishell.h"
+#include <stdlib.h>
+#include <sys/_types/_pid_t.h>
+#include <sys/_types/_s_ifmt.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+int execute_cmd(t_cmd *cmd, t_env *env)
+{
+ int result;
+ char *cmd_path;
+ int fd;
+
+ cmd_path = get_cmd_path(cmd->args[0], env);
+ cmd->args[0] = cmd_path;
+
+ if (cmd->redirs[0].type == INPUT_FILE)
+ {
+ fd = open(cmd->redirs[0].specifier, O_RDONLY);
+ if (fd < 0)
+ return (EXIT_FAILURE);
+ dup2(fd, STDIN_FILENO);
+ }
+ else if (cmd->redirs[0].type == INPUT_LIMITER)
+ {
+ dbg("INPUT_LIMITER");
+ }
+ if (cmd->redirs[1].type == OUTPUT_APPEND)
+ {
+ dbg("OUTPUT_APPEND");
+ fd = open(cmd->redirs[1].specifier, O_WRONLY | O_CREAT | O_APPEND);
+ if (fd < 0)
+ return (EXIT_FAILURE);
+ dup2(fd, STDOUT_FILENO);
+ }
+ else if (cmd->redirs[1].type == OUTPUT_OVERRIDE)
+ {
+ fd = open(cmd->redirs[1].specifier, O_WRONLY | O_CREAT | O_TRUNC);
+ if (fd < 0)
+ return (EXIT_FAILURE);
+ dup2(fd, STDOUT_FILENO);
+ dbg("OUTPUT_OVERRIDE");
+ }
+ result = execve(cmd->args[0], cmd->args, env_to_strlst(env));
+ return (result);
+}
+
+static int eval_cmd(t_cmd *cmd, t_env **env)
+{
+ if (ft_strncmp(cmd->args[0], "pwd", 4) == 0)
+ pwd(*env);
+ else if (ft_strncmp(cmd->args[0], "echo", 5) == 0)
+ echo(cmd->args);
+ else if (ft_strncmp(cmd->args[0], "env", 4) == 0)
+ ft_env(*env);
+ else if (ft_strncmp(cmd->args[0], "cd", 3) == 0)
+ cd(env, cmd->args);
+ else if (ft_strncmp(cmd->args[0], "unset", 6) == 0)
+ unset(cmd->args, env);
+ else if (ft_strncmp(cmd->args[0], "export", 7) == 0)
+ export(cmd->args, env);
+ return (0);
+} \ No newline at end of file
diff --git a/src/get_cmd_path.c b/src/get_cmd_path.c
new file mode 100644
index 0000000..1ecf393
--- /dev/null
+++ b/src/get_cmd_path.c
@@ -0,0 +1,82 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* get_cmd_path.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/10/17 16:45:47 by dkaiser #+# #+# */
+/* Updated: 2024/10/17 17:11:27 by dkaiser ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft.h"
+#include "minishell.h"
+
+static char *get_absolute_cmd_path(char *cmd, t_env *env);
+static char *find_in_path(char *cmd, t_env *env);
+char **get_split_path(t_env *env);
+
+char *get_cmd_path(char *cmd, t_env *env)
+{
+ if (cmd[0] == '/')
+ return (ft_strdup(cmd));
+ else if (ft_strchr(cmd, '/'))
+ return (get_absolute_cmd_path(cmd, env));
+ else
+ return (find_in_path(cmd, env));
+}
+
+static char *get_absolute_cmd_path(char *cmd, t_env *env)
+{
+ char *cur_dir;
+ char *result;
+
+ cur_dir = ft_strjoin(env_get(env, "PWD"), "/");
+ if (!cur_dir)
+ return (NULL);
+ result = ft_strjoin(cur_dir, cmd);
+ free(cur_dir);
+ if (!result)
+ return (NULL);
+ if (access(result, X_OK) == -1)
+ {
+ free(result);
+ return (NULL);
+ }
+ return (result);
+}
+
+static char *find_in_path(char *cmd, t_env *env)
+{
+ char *cur_path;
+ char *cmd_path;
+ char **path;
+
+ path = get_split_path(env);
+ cmd_path = NULL;
+ while (*path)
+ {
+ if (cmd_path)
+ free(cmd_path);
+ cur_path = ft_strjoin(*path, "/");
+ if (!cur_path)
+ return (NULL);
+ cmd_path = ft_strjoin(cur_path, cmd);
+ free(cur_path);
+ if (!cmd_path)
+ return (NULL);
+ if (access(cmd_path, X_OK) != -1)
+ return (cmd_path);
+ path++;
+ }
+ return (NULL);
+}
+
+char **get_split_path(t_env *env)
+{
+ char *path;
+
+ path = env_get(env, "PATH");
+ return (ft_split(path, ':'));
+}
diff --git a/src/interpreter.c b/src/interpreter.c
new file mode 100644
index 0000000..c6a4a00
--- /dev/null
+++ b/src/interpreter.c
@@ -0,0 +1,90 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* interpreter.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/08/05 13:15:24 by dkaiser #+# #+# */
+/* Updated: 2024/10/25 20:59:16 by chuhlig ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "debug_tools.h"
+#include "minishell.h"
+#include <stdlib.h>
+#include <sys/_types/_pid_t.h>
+#include <sys/cdefs.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+static int eval_rec(t_node *node, t_env *env, int in_fd);
+
+int eval(t_node *node, t_env *env)
+{
+ pid_t pid;
+ int result;
+
+ if (node == NULL)
+ return (EXIT_FAILURE);
+ result = 0;
+ pid = fork();
+ if (pid < 0)
+ {
+ return (EXIT_FAILURE);
+ }
+ if (pid == 0)
+ {
+ result = eval_rec(node, env, STDIN_FILENO);
+ exit(result);
+ }
+ else
+ {
+ waitpid(pid, &result, 0);
+ }
+ return (result);
+}
+
+static int eval_rec(t_node *node, t_env *env, int in_fd)
+{
+ pid_t pid;
+ int result;
+ int p[2];
+
+ result = pipe(p);
+ if (result == -1)
+ return (EXIT_FAILURE);
+ if (node->type == PIPE_NODE)
+ {
+ pid = fork();
+ if (pid < 0)
+ {
+ return (EXIT_FAILURE);
+ }
+ if (pid == 0)
+ {
+ close(p[0]);
+ dup2(in_fd, STDIN_FILENO);
+ dup2(p[1], STDOUT_FILENO);
+ result = execute_cmd(&node->content.pipe.left->content.cmd, env);
+ exit(result);
+ }
+ else
+ {
+ close(p[1]);
+ dup2(p[0], STDIN_FILENO);
+ result = eval_rec(node->content.pipe.right, env, p[0]);
+ }
+ }
+ else if (node->type == CMD_NODE)
+ {
+ result = execute_cmd(&node->content.cmd, env);
+ }
+ else
+ {
+ panic(UNREACHABLE);
+ return (EXIT_FAILURE);
+ }
+ return (result);
+}
+
diff --git a/src/main.c b/src/main.c
index 8523b9e..4e1d9da 100644
--- a/src/main.c
+++ b/src/main.c
@@ -6,15 +6,22 @@
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/22 17:14:03 by dkaiser #+# #+# */
-/* Updated: 2024/07/18 16:44:14 by chuhlig ### ########.fr */
+/* Updated: 2024/08/26 19:55:57 by chuhlig ### ########.fr */
+/* Updated: 2024/10/25 16:06:32 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
#include "../include/minishell.h"
-int main(void)
+int main(int argc, char *argv[], char *envp[])
{
+ t_env *env;
+
+ env = NULL;
+ if (!argc && !argv)
+ return (1);
if (init())
return (1);
- repl("Minishell $ ");
+ getenvlst(&env, envp);
+ repl("Minishell $ ", &env);
}
diff --git a/src/new_token.c b/src/new_token.c
index 92ff421..6431c7d 100644
--- a/src/new_token.c
+++ b/src/new_token.c
@@ -3,10 +3,10 @@
/* ::: :::::::: */
/* new_token.c :+: :+: :+: */
/* +:+ +:+ +:+ */
-/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/27 14:29:44 by dkaiser #+# #+# */
-/* Updated: 2024/06/28 14:59:34 by dkaiser ### ########.fr */
+/* Updated: 2024/08/29 15:30:52 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
@@ -50,3 +50,28 @@ t_token *new_redir_token(int type, t_token *previous, t_token *next)
token->content.redir_type = type;
return (token);
}
+
+// void ft_append_token(int type, t_token **list)// but we need somewhere token/node head initialize with nul
+// {
+// t_token *node;
+// t_token *last_node;
+
+// if (!list)
+// return ;
+// node = malloc(sizeof(t_token));
+// if (!node)
+// return ;
+// node->next = NULL;
+// node->type = type;
+// if (!*list)
+// {
+// *list = node;
+// node->previous = NULL;
+// }
+// else
+// {
+// last_node = ft_lstlast(*list);
+// last_node->next = node;
+// node->previous = last_node;
+// }
+// } \ No newline at end of file
diff --git a/src/repl.c b/src/repl.c
index d590fec..9fae849 100644
--- a/src/repl.c
+++ b/src/repl.c
@@ -6,14 +6,14 @@
/* 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: 2024/10/22 17:05:14 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */
#include "../include/minishell.h"
#include "token.h"
-void repl(const char *prompt)
+void repl(const char *prompt, t_env **env)
{
char *input;
t_token *token_list;
@@ -31,7 +31,10 @@ void repl(const char *prompt)
tokenizer(input, &token_list, '\0');
lines = parse(token_list);
if (lines)
+ {
print_ast(lines->content);
+ eval(lines->content, env);
+ }
free(input);
}
}
diff --git a/src/tokenizer.c b/src/tokenizer.c
index ab8a6ac..d7a96f7 100644
--- a/src/tokenizer.c
+++ b/src/tokenizer.c
@@ -6,7 +6,7 @@
/* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/28 20:55:50 by chuhlig #+# #+# */
-/* Updated: 2024/08/29 15:26:55 by dkaiser ### ########.fr */
+/* Updated: 2024/10/17 14:21:26 by chuhlig ### ########.fr */
/* */
/* ************************************************************************** */