#ifndef AST_BASE_H #define AST_BASE_H #include #include enum ast_type { AST_END, AST_LIST, AST_IF, AST_AND_OR, AST_REDIR, AST_VOID, AST_CMD, AST_WORD, AST_PIPE, AST_NEG, AST_LOOP, AST_ASSIGNMENT }; struct ast { enum ast_type type; /** * Data associated with this AST node. It can be one of the following: * - NULL (AST_END) * - struct ast_if* (AST_IF) * - struct ast_command* (AST_CMD) * - struct ast_and_or* (AST_AND_OR) * - struct ast_redir* (AST_REDIR) * - and a lot more now... */ void *data; }; /* @brief: returns an ast* with corresponding data and type. * * @note: this function should only be called by ast_create_[TYPE] functions. */ struct ast *ast_create(enum ast_type type, void *data); /* @brief: frees the given ast. If ast is NULL, does nothing. * */ void ast_free(struct ast **node); #endif /* ! AST_BASE_H */