aboutsummaryrefslogtreecommitdiff
path: root/include/ast.h
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-06-14 10:36:53 +0200
committerCharles <sircharlesaze@gmail.com>2020-06-14 10:36:53 +0200
commit26ddbd7146f65a2cf100713f422a9ab5b1890620 (patch)
tree76daa703ee5ea4c3eafcbce0f8127ab5c92983ab /include/ast.h
parentab1e32c348c649c1c7c8dad5922cfe1c0f11ac5d (diff)
downloadminishell-26ddbd7146f65a2cf100713f422a9ab5b1890620.tar.gz
minishell-26ddbd7146f65a2cf100713f422a9ab5b1890620.tar.bz2
minishell-26ddbd7146f65a2cf100713f422a9ab5b1890620.zip
Changing ast related struct and fixing functions accordingly
Diffstat (limited to 'include/ast.h')
-rw-r--r--include/ast.h95
1 files changed, 31 insertions, 64 deletions
diff --git a/include/ast.h b/include/ast.h
index 2f3a11d..790ac29 100644
--- a/include/ast.h
+++ b/include/ast.h
@@ -6,7 +6,7 @@
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/01 17:05:38 by charles #+# #+# */
-/* Updated: 2020/06/09 11:44:45 by charles ### ########.fr */
+/* Updated: 2020/06/14 10:28:53 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,30 +20,8 @@
# include <stdlib.h>
# include <stdbool.h>
-# include "libft_mem.h"
-# include "libft_util.h"
-
-/*
-** \brief Separator type
-** \param SEP_END `;` Regular command end
-** \param SEP_PIPE `|` Pipe output of left to right
-** \param SEP_AND `&&` Execute right if left status == 0
-** \param SEP_OR `||` Execute right if left status != 0
-*/
-
-typedef enum e_bool
-{
- TRUE,
- FALSE,
-} t_bool;
-
-typedef enum e_sep
-{
- SEP_END,
- SEP_PIPE,
- SEP_AND,
- SEP_OR,
-} t_sep;
+# include "libft_lst.h"
+# include "lexer.h"
struct s_ast;
@@ -54,29 +32,12 @@ struct s_ast;
** \param sep Type of separator
*/
-typedef struct s_line
-{
- struct s_ast *left;
- struct s_ast *right;
- e_token_tag sep;
-} t_line;
-
-/*
-** \brief Command struct
-** \param argv Array of string,
-** all arguments beginning with executable name
-** \param in STDIN redirection filename
-** \param out STDOUT redirection filename
-** \param is_append True if out redirection is append to file
-*/
-
-typedef struct s_cmd
+typedef struct s_line
{
- t_ftlst *argv; // change to t_ftvec of t_token
- t_token *in; // change to t_token
- t_token *out; // change to t_token
- bool is_append;
-} t_cmd;
+ struct s_ast *left;
+ struct s_ast *right;
+ enum e_token_tag sep;
+} t_line;
/*
** \brief AST node tag (type)
@@ -84,37 +45,43 @@ typedef struct s_cmd
** \param TAG_LINE Line AST node
*/
-typedef enum e_ast_tag
+enum e_ast_tag
{
- TAG_CMD,
- TAG_LINE,
-} t_ast_tag;
+ AST_CMD,
+ AST_LINE,
+};
/*
** \brief AST node struct
** \param tag Node tag
-** \param cmd Command struct
** \param line Line struct
+** \param cmd_argv Array of string tokens
+** \param in STDIN redirection string tokens
+** \param out STDOUT redirection string tokens
+** \param is_append True if out redirection is append to file
*/
-typedef struct s_ast
+typedef struct s_ast
{
- t_ast_tag tag;
+ enum e_ast_tag tag;
union
{
- t_line line;
- t_cmd cmd;
+ t_line line;
+ t_ftlst *cmd_argv;
};
-} t_ast;
+ t_ftlst *in;
+ t_ftlst *out;
+ bool is_append;
+} t_ast;
-typedef struct s_ret
+typedef struct s_ret
{
- t_token *unexpected;
- t_ast *ast;
- t_ftlst *rest;
-} t_ret;
+ t_token *unexpected;
+ t_ast *ast;
+ t_ftlst *rest;
+} t_ret;
-t_ast *ast_new(t_ast_tag tag, void *data);
-void ast_destroy(t_ast *ast);
+t_ast *ast_new(enum e_ast_tag tag);
+void ast_destroy(t_ast *ast);
#endif