From 454d439575489934791c04329df6e82e56dabf54 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Thu, 27 Aug 2020 09:29:42 +0200 Subject: Renaming e_token_tag -> e_tok --- include/ast.h | 2 +- include/eval.h | 2 +- include/lexer.h | 29 ++++++++++++++++++++--------- include/parser.h | 4 ++-- src/eval/redir.c | 4 ++-- src/lexer/lexer.c | 6 +++--- src/lexer/lexer_utils.c | 4 ++-- src/lexer/token.c | 8 ++++---- src/parse/cmd_parse.c | 2 +- src/parse/parse.c | 8 ++++---- src/parse/redir_parse.c | 2 +- src/preprocess.c | 2 +- 12 files changed, 42 insertions(+), 31 deletions(-) diff --git a/include/ast.h b/include/ast.h index a767444..7fec75d 100644 --- a/include/ast.h +++ b/include/ast.h @@ -37,7 +37,7 @@ typedef struct s_op { struct s_ast *left; struct s_ast *right; - enum e_token_tag sep; + enum e_tok sep; } t_op; /* diff --git a/include/eval.h b/include/eval.h index 88b6578..f2920b2 100644 --- a/include/eval.h +++ b/include/eval.h @@ -58,7 +58,7 @@ int eval(int fds[2], t_env env, t_path path, t_ast *ast); int fork_wrap(int fds[2], void *passed, int (*wrapped)(void *param)); int eval_cmd(int fds[2], t_env env, t_path path, t_ast *ast); -t_ftlst *split_token(t_ftlst **lst, enum e_token_tag); +t_ftlst *split_token(t_ftlst **lst, enum e_tok); /* ** redir.c diff --git a/include/lexer.h b/include/lexer.h index 27910a5..89917d3 100644 --- a/include/lexer.h +++ b/include/lexer.h @@ -6,7 +6,7 @@ /* By: nahaddac +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/19 10:51:26 by nahaddac #+# #+# */ -/* Updated: 2020/08/19 13:41:08 by charles ### ########.fr */ +/* Updated: 2020/08/27 09:26:33 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,7 @@ # include "libft_str.h" # include "minishell.h" -enum e_token_tag +enum e_tok { TAG_AND = 1 << 0, TAG_END = 1 << 1, @@ -41,13 +41,13 @@ enum e_token_tag typedef struct { - enum e_token_tag tag; + enum e_tok tag; char *content; } t_token; t_ftlst *lexer(char *input); -enum e_token_tag ret_token(char *input, int i); -enum e_token_tag ret_token_sep_redir_append(char *input, int i); +enum e_tok ret_token(char *input, int i); +enum e_tok ret_token_sep_redir_append(char *input, int i); int lexer_sep(char input); int lexer_verif_entre_cote(char *input, int i); @@ -62,15 +62,26 @@ t_ftlst *lexe_trim_out(t_ftlst *lst); ** token.c */ -t_token *token_new(enum e_token_tag tag, char *content); -t_token *token_new_until(enum e_token_tag tag, char *content, int n); +t_token *token_new(enum e_tok tag, char *content); +t_token *token_new_until(enum e_tok tag, char *content, int n); void token_destroy(t_token *token); void token_destroy_lst(t_ftlst *tokens); void token_destroy_lst2(t_ftlst *tokens1, t_ftlst *tokens2); -enum e_token_tag token_tag(t_ftlst *token_lst); -void token_set_tag(t_ftlst *token_lst, enum e_token_tag tag); +enum e_tok token_tag(t_ftlst *token_lst); +void token_set_tag(t_ftlst *token_lst, enum e_tok tag); char *token_content(t_ftlst *token_lst); void token_set_content(t_ftlst *token_lst, char *content); void token_set_contentf(t_ftlst *token_lst, char *content); +/* +** \warning DO NOT change the order of the fields +*/ + +typedef struct s_tlst +{ + char *content; + struct s_tlst *next; + enum e_tok tag; +} t_tlst; + #endif diff --git a/include/parser.h b/include/parser.h index 0bdc679..d228dca 100644 --- a/include/parser.h +++ b/include/parser.h @@ -52,8 +52,8 @@ t_ftlst *push_token(t_ftlst **tokens, t_token *pushed); t_ast *push_cmd(t_ast *ast, t_ftlst *ret); t_ast *push_redir(t_ast *ast, t_ftlst *rest); -int parse_cmd_str_true_false(enum e_token_tag tag); -int parse_redir_true_false(enum e_token_tag tag); +int parse_cmd_str_true_false(enum e_tok tag); +int parse_redir_true_false(enum e_tok tag); // error t_token *error_syntax_simple(t_ftlst *in); diff --git a/src/eval/redir.c b/src/eval/redir.c index 49cfa1d..8f3a266 100644 --- a/src/eval/redir.c +++ b/src/eval/redir.c @@ -6,13 +6,13 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/15 11:05:34 by charles #+# #+# */ -/* Updated: 2020/07/19 18:57:03 by charles ### ########.fr */ +/* Updated: 2020/08/27 09:28:55 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "eval.h" -static enum e_token_tag st_lst_tag(t_ftlst *lst) +static enum e_tok st_lst_tag(t_ftlst *lst) { return (((t_token*)lst->data)->tag); } diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c index 2e16eab..6a8a0ca 100644 --- a/src/lexer/lexer.c +++ b/src/lexer/lexer.c @@ -99,7 +99,7 @@ int check_input_out(char *input) return(0); } -enum e_token_tag token_verif_stick(t_token *lst_token) +enum e_tok token_verif_stick(t_token *lst_token) { int i; @@ -110,7 +110,7 @@ enum e_token_tag token_verif_stick(t_token *lst_token) return(lst_token->tag | TAG_STICK); } -enum e_token_tag token_str_or_cote(t_token *lst_token) +enum e_tok token_str_or_cote(t_token *lst_token) { int i; @@ -139,7 +139,7 @@ enum e_token_tag token_str_or_cote(t_token *lst_token) t_token *push_token_enum(t_token *lst_token) { - enum e_token_tag tk; + enum e_tok tk; tk = ret_token(lst_token->content, 0); if (tk == 0) diff --git a/src/lexer/lexer_utils.c b/src/lexer/lexer_utils.c index 3a1378c..74b1fa4 100644 --- a/src/lexer/lexer_utils.c +++ b/src/lexer/lexer_utils.c @@ -13,7 +13,7 @@ #include "lexer.h" // check for append tag -enum e_token_tag ret_token_sep_redir_append(char *input, int i) +enum e_tok ret_token_sep_redir_append(char *input, int i) { if (input[i + 1] == '>') return(TAG_REDIR_APPEND); @@ -22,7 +22,7 @@ enum e_token_tag ret_token_sep_redir_append(char *input, int i) } // return token tag corresponding to string id -enum e_token_tag ret_token(char *input, int i) +enum e_tok ret_token(char *input, int i) { if (input[i] == ';') return(TAG_END); diff --git a/src/lexer/token.c b/src/lexer/token.c index 43971de..9904351 100644 --- a/src/lexer/token.c +++ b/src/lexer/token.c @@ -12,7 +12,7 @@ #include "lexer.h" -t_token *token_new(enum e_token_tag tag, char *content) +t_token *token_new(enum e_tok tag, char *content) { size_t len; @@ -22,7 +22,7 @@ t_token *token_new(enum e_token_tag tag, char *content) return (token_new_until(tag, content, len)); } -t_token *token_new_until(enum e_token_tag tag, char *content, int n) +t_token *token_new_until(enum e_tok tag, char *content, int n) { t_token *token; @@ -56,12 +56,12 @@ void token_destroy_lst2(t_ftlst *tokens1, t_ftlst *tokens2) ft_lstdestroy(&tokens2, (void (*)(void*))token_destroy); } -enum e_token_tag token_tag(t_ftlst *token_lst) +enum e_tok token_tag(t_ftlst *token_lst) { return (((t_token*)token_lst->data)->tag); } -void token_set_tag(t_ftlst *token_lst, enum e_token_tag tag) +void token_set_tag(t_ftlst *token_lst, enum e_tok tag) { ((t_token*)token_lst->data)->tag = tag; } diff --git a/src/parse/cmd_parse.c b/src/parse/cmd_parse.c index 25802c1..bb68dac 100644 --- a/src/parse/cmd_parse.c +++ b/src/parse/cmd_parse.c @@ -2,7 +2,7 @@ #include "parser.h" -int parse_cmd_str_true_false(enum e_token_tag tag) +int parse_cmd_str_true_false(enum e_tok tag) { if (tag & TAG_STR || tag & TAG_STR_DOUBLE || tag & TAG_STR_SINGLE) return (1); diff --git a/src/parse/parse.c b/src/parse/parse.c index 29b3ccb..b1df5ce 100644 --- a/src/parse/parse.c +++ b/src/parse/parse.c @@ -42,7 +42,7 @@ t_ret *ret_wrap_ast(t_ast *ast, t_ftlst *rest) t_ret *parse_redir(t_ftlst *input, t_ftlst **redirs) { - enum e_token_tag tag; + enum e_tok tag; t_ret *tmp; push_token(redirs, input->data); @@ -77,7 +77,7 @@ t_ret *parse_redir(t_ftlst *input, t_ftlst **redirs) t_ret *parse_cmd(t_ftlst *input) { - enum e_token_tag tag; + enum e_tok tag; t_ast *ast; t_ret *tmp; @@ -120,7 +120,7 @@ t_ret *parse_op(t_ftlst *input) t_ast *ast; t_ret *left_ret; t_ret *right_ret; - enum e_token_tag tag; + enum e_tok tag; t_ret *tmp; left_ret = parse_expr(input); @@ -159,7 +159,7 @@ t_ret *parse_op(t_ftlst *input) t_ret *parse_expr(t_ftlst *input) { t_ret *tmp; - enum e_token_tag tag; + enum e_tok tag; t_ast *new_ast; tag = ((t_token*)input->data)->tag; diff --git a/src/parse/redir_parse.c b/src/parse/redir_parse.c index 768506e..ebd6583 100644 --- a/src/parse/redir_parse.c +++ b/src/parse/redir_parse.c @@ -1,7 +1,7 @@ #include "parser.h" -int parse_redir_true_false(enum e_token_tag tag) +int parse_redir_true_false(enum e_tok tag) { if (tag & TAG_IS_REDIR) return (1); diff --git a/src/preprocess.c b/src/preprocess.c index 5782a45..f594969 100644 --- a/src/preprocess.c +++ b/src/preprocess.c @@ -82,7 +82,7 @@ char **st_tokens_to_argv(t_ftlst *tokens) char **preprocess(t_ftlst **tokens, t_env env) { t_ftlst *curr; - enum e_token_tag prev_tag; + enum e_tok prev_tag; prev_tag = 0; curr = *tokens; -- cgit