#include "ast_neg.h" #include #include struct ast_neg *ast_get_neg(struct ast *node) { if (node == NULL || node->type != AST_NEG) return NULL; return node->data; } struct ast *ast_create_neg(bool negation, struct ast *child) { struct ast_neg *neg_data = malloc(sizeof(struct ast_neg)); if (neg_data == NULL) { perror("Error: could not allocate more memory"); return NULL; } neg_data->negation = negation; neg_data->child = child; struct ast *result = ast_create(AST_NEG, neg_data); if (result == NULL) free(neg_data); return result; } void ast_free_neg(struct ast_neg *node) { if (node == NULL) return; ast_free(&node->child); free(node); }