summaryrefslogtreecommitdiff
path: root/42sh/src/exec/ast_eval.c
blob: db152f8def312a86125a53b438b86fa0d3886753 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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);
}