feat: toujours les mêmes qui font les pipes. Plus de assert dans ASTs (pour des raisons évidentes de stabilité du code) et nouveaux types (AST_PIPE et AST_NEG), + modifs random dans le parser
This commit is contained in:
parent
07e7d83c60
commit
96626d9850
27 changed files with 238 additions and 86 deletions
32
src/utils/ast/ast_neg.c
Normal file
32
src/utils/ast/ast_neg.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include "ast_neg.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
bool ast_is_neg(struct ast *node)
|
||||
{
|
||||
return node != NULL && node->type == AST_REDIR;
|
||||
}
|
||||
|
||||
struct ast_neg *ast_get_neg(struct ast *node)
|
||||
{
|
||||
if (ast_is_neg(node))
|
||||
return node->data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ast *ast_create_neg(bool negation, struct ast *child)
|
||||
{
|
||||
struct ast_neg *node = malloc(sizeof(struct ast_neg));
|
||||
if (!node)
|
||||
return NULL;
|
||||
|
||||
return ast_create(AST_NEG, node);
|
||||
}
|
||||
|
||||
void ast_free_neg(struct ast_neg *node)
|
||||
{
|
||||
if (!node)
|
||||
return;
|
||||
ast_free(&node->child);
|
||||
free(node);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue