diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/minishell.h | 24 | ||||
| -rw-r--r-- | include/parser.h | 35 |
2 files changed, 36 insertions, 23 deletions
diff --git a/include/minishell.h b/include/minishell.h index d205e29..4181c46 100644 --- a/include/minishell.h +++ b/include/minishell.h @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/26 15:33:51 by cacharle #+# #+# */ -/* Updated: 2020/10/09 20:40:08 by charles ### ########.fr */ +/* Updated: 2020/10/10 08:08:21 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -60,8 +60,7 @@ typedef struct { int last_status; char *progname; - pid_t pids[STATE_PIDS_MAX_SIZE]; - size_t pids_len; + pid_t child_pid; bool killed; bool is_child; } t_state; @@ -126,6 +125,9 @@ int builtin_exit(char **argv, t_env env); char **preprocess(t_tok_lst **tokens, t_env env); int preprocess_filename( t_tok_lst **tokens, t_env env, char **filename); +size_t interpolate( + char *str, size_t i, t_tok_lst **curr_addr, + enum e_tok prev_tag, t_env env); /* ** signal.c @@ -149,7 +151,19 @@ bool utils_strisblank(char *str); bool setup(char *first_arg, t_env env); -size_t interpolate( - char *str, size_t i, t_tok_lst **curr_addr, enum e_tok prev_tag, t_env env); + +/* +** debug.c +*/ + +# ifdef MINISHELL_TEST + +# include "parser.h" + +int debug_lexer(char *input); +int debug_parser(char *input); +void ast_print(int level, t_ast *ast); + +# endif #endif diff --git a/include/parser.h b/include/parser.h index bd4e5b0..4bf79df 100644 --- a/include/parser.h +++ b/include/parser.h @@ -6,12 +6,12 @@ /* By: cacharle <cacharle@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/28 09:00:00 by cacharle #+# #+# */ -/* Updated: 2020/10/09 16:02:40 by cacharle ### ########.fr */ +/* Updated: 2020/10/10 07:37:55 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ -#ifndef PARSE_H -# define PARSE_H +#ifndef PARSER_H +# define PARSER_H /* ** \file parser.h @@ -36,7 +36,7 @@ # include "lexer.h" # include "error.h" -struct s_ast; +struct s_ast; /* ** \brief Operation struct @@ -45,12 +45,11 @@ struct s_ast; ** \param sep Type of separator */ - typedef struct s_op { struct s_ast *left; struct s_ast *right; - enum e_tok sep; + enum e_tok sep; } t_op; /* @@ -77,18 +76,18 @@ enum e_ast ** \param pipline List of commands in a pipeline ** \param parend_ast AST inside parenthesis ** \param redirs Redirections tokens +** \note Norminette doesn't like unamed union +** It breaks my heart to waste memory but +** t_ast isn't heavily used anyway */ typedef struct s_ast { enum e_ast tag; - union - { - t_op op; - t_tok_lst *cmd_argv; - t_ftlst *pipeline; - struct s_ast *parent_ast; - }; + t_op op; + t_tok_lst *cmd_argv; + t_ftlst *pipeline; + struct s_ast *parent_ast; t_tok_lst *redirs; } t_ast; @@ -112,8 +111,8 @@ typedef struct s_parsed t_parsed *parsed_new(t_ast *ast, t_tok_lst *rest); t_parsed *parsed_error(const char *format, ...); -t_parsed *parsed_expected(void); -t_parsed *parsed_unexpected(char *content); +t_parsed *parsed_expected(void); +t_parsed *parsed_unexpected(char *content); void parsed_destroy(t_parsed *parsed); /* @@ -121,8 +120,8 @@ void parsed_destroy(t_parsed *parsed); */ t_parsed *parse(t_tok_lst *input); -t_parsed *parse_op(t_tok_lst *input); -t_parsed *parse_expr(t_tok_lst *input); -t_parsed *parse_cmd(t_tok_lst *input); +t_parsed *parse_op(t_tok_lst *input); +t_parsed *parse_expr(t_tok_lst *input); +t_parsed *parse_cmd(t_tok_lst *input); #endif |
