diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/ast.h | 95 | ||||
| -rw-r--r-- | include/eval.h | 6 | ||||
| -rw-r--r-- | include/parser.h (renamed from include/parse.h) | 6 |
3 files changed, 37 insertions, 70 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 diff --git a/include/eval.h b/include/eval.h index fc149b2..8fbbb1c 100644 --- a/include/eval.h +++ b/include/eval.h @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:05:30 by charles #+# #+# */ -/* Updated: 2020/05/04 11:58:16 by charles ### ########.fr */ +/* Updated: 2020/06/14 10:33:54 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -75,7 +75,7 @@ char *exec_search_path(t_path path, char *path_var, char *exec_name); ** pipe.c */ -int pipe_setup_parent(t_cmd *cmd, int pipe_in[2], int pipe_out[2]); -int pipe_setup_child(int pipe_in[2], int pipe_out[2]); +// int pipe_setup_parent(t_cmd *cmd, int pipe_in[2], int pipe_out[2]); +// int pipe_setup_child(int pipe_in[2], int pipe_out[2]); #endif diff --git a/include/parse.h b/include/parser.h index 6cb50b8..80d039b 100644 --- a/include/parse.h +++ b/include/parser.h @@ -1,12 +1,12 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* parse.h :+: :+: :+: */ +/* parser.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/28 09:00:00 by cacharle #+# #+# */ -/* Updated: 2020/06/13 11:59:47 by charles ### ########.fr */ +/* Updated: 2020/06/14 10:31:20 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,6 +43,6 @@ ** parse.c */ -t_ast *parse(t_ftlst *lst); +t_ret *parse(t_ftlst *input); #endif |
