42sh/src/utils/ast/ast_base.h
Jean Herail bf992f2db4 Implemented some ast handlings...
ast lists, and_or, redirection and builtins
2026-01-17 17:33:22 +01:00

43 lines
834 B
C

#ifndef AST_BASE_H
#define AST_BASE_H
#include <stdlib.h>
enum ast_type
{
AST_END,
AST_LIST,
AST_IF,
AST_AND_OR,
AST_REDIR,
AST_VOID,
AST_CMD
};
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)
*/
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 */