#ifndef AST_LOOP_H #define AST_LOOP_H #include "ast_base.h" struct ast_loop { // Repeat body while condition is true struct ast *condition; struct ast *body; }; /** * Checks if the given AST node is a loop. */ bool ast_is_loop(struct ast *node); /** * Retrieves the loop data from the given AST node. * Assumes that the node is of type AST_LOOP. */ struct ast_loop *ast_get_loop(struct ast *node); /** * Creates a new AST node representing a loop. */ struct ast *ast_create_loop(struct ast* condition, struct ast* body); /* * @brief: frees the given ast_loop and sets the pointer to NULL. */ void ast_free_loop(struct ast_loop *loop_node); #endif /* ! AST_LOOP_H */