summaryrefslogtreecommitdiff
path: root/42sh/src/exec/ast_eval.c
diff options
context:
space:
mode:
Diffstat (limited to '42sh/src/exec/ast_eval.c')
-rw-r--r--42sh/src/exec/ast_eval.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/42sh/src/exec/ast_eval.c b/42sh/src/exec/ast_eval.c
new file mode 100644
index 0000000..db152f8
--- /dev/null
+++ b/42sh/src/exec/ast_eval.c
@@ -0,0 +1,20 @@
+#include "exec/ast_eval.h"
+
+#include "exec/ast_exec_functions.h"
+
+static const exec_f exec_node_ltable[] = {
+ [AST_LIST] = exec_ast_list, [AST_IF] = exec_ast_if,
+ [AST_COMMAND] = exec_ast_command, [AST_LOGICAL] = exec_ast_logical,
+ [AST_PIPELINE] = exec_ast_pipe, [AST_REDIRECTION] = exec_ast_redirection,
+ [AST_WHILE] = exec_ast_while, [AST_ASSIGN] = exec_ast_assign,
+ [AST_FOR] = exec_ast_for, [AST_SUBSHELL] = exec_ast_subshell
+};
+
+int eval_ast(struct ast *ast)
+{
+ if (!ast)
+ {
+ return SHELL_TRUE;
+ }
+ return exec_node_ltable[ast->type](ast);
+}