Implemented some ast handlings...
ast lists, and_or, redirection and builtins
This commit is contained in:
parent
1fc54e2bf3
commit
bf992f2db4
10 changed files with 359 additions and 14 deletions
35
src/utils/ast/ast_and_or.c
Normal file
35
src/utils/ast/ast_and_or.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#include "utils/ast/ast_and_or.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
bool ast_is_and_or(struct ast *node)
|
||||
{
|
||||
return node != NULL && node->type == AST_AND_OR;
|
||||
}
|
||||
|
||||
struct ast_and_or *ast_get_and_or(struct ast *node)
|
||||
{
|
||||
if (ast_is_and_or(node))
|
||||
return (struct ast_and_or *)node->data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ast *ast_create_and_or(struct ast *left, struct ast *right, enum ast_and_or_type type)
|
||||
{
|
||||
struct ast_and_or *and_or = malloc(sizeof(struct ast_and_or));
|
||||
if (!and_or)
|
||||
return NULL;
|
||||
and_or->left = left;
|
||||
and_or->right = right;
|
||||
and_or->type = type;
|
||||
|
||||
return ast_create(AST_AND_OR, and_or);
|
||||
}
|
||||
|
||||
void ast_free_and_or(struct ast_and_or *and_or)
|
||||
{
|
||||
if (!and_or)
|
||||
return;
|
||||
ast_free(&and_or->left);
|
||||
ast_free(&and_or->right);
|
||||
free(and_or);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue