Implemented some ast handlings...

ast lists, and_or, redirection and builtins
This commit is contained in:
Jean Herail 2026-01-17 17:33:22 +01:00
parent 1fc54e2bf3
commit bf992f2db4
10 changed files with 359 additions and 14 deletions

View 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);
}