Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
** exec_node.c for 42sh in /home/seblu
**
** Made by Seblu
** Login <seblu@epita.fr>
**
** Started on Sat Mar 25 14:51:09 2006 Seblu
** Last update Sat Apr 15 09:12:38 2006 Seblu
*/
#include "execution.h"
#include "mem.h"
/*!
** Execute a node of ast by calling the good function
**
** @param node node to execute
** @param sh shell struct
*/
void exec_node(struct s_ast *node, struct s_42sh *sh)
{
assert(sh);
if (node == NULL)
return;
else if (node->type == T_CMD)
exec_cmd(&node->data.node_cmd, sh);
else if (node->type == T_PIPE)
exec_pipe(&node->data.node_op, sh);
else if (node->type == T_LINE)
exec_line(&node->data.node_op, sh);
else if (node->type == T_SEP_AND)
exec_sepand(&node->data.node_op, sh);
else if (node->type == T_SEP_SEMICOMMA)
exec_sepsemicolon(&node->data.node_op, sh);
else if (node->type == T_IF)
exec_if(&node->data.node_if, sh);
else if (node->type == T_FOR)
exec_for(&node->data.node_for, sh);
else if (node->type == T_AND)
exec_and(&node->data.node_op, sh);
else if (node->type == T_OR)
exec_or(&node->data.node_op, sh);
else if (node->type == T_WHILE)
exec_while(&node->data.node_while, sh);
else if (node->type == T_UNTIL)
exec_until(&node->data.node_while, sh);
else if (node->type == T_BANG)
exec_bang(&node->data.node_op, sh);
else if (node->type == T_SUBSHELL)
exec_subshell(&node->data.node_subshell, sh);
else
assert(0);
}