#include "ast_and_or.h" #include 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); }