From 72ee131562574c4a6cb69800cdd81268b52ace84 Mon Sep 17 00:00:00 2001 From: nass1pro Date: Sun, 14 Jun 2020 17:31:01 +0200 Subject: Change file cmd --- src/lexer/lexer.c | 7 ++++--- src/main.c | 2 +- src/parse/cmd_parse.c | 27 +++++++++++++++++++++++++++ src/parse/parse.c | 29 ++++------------------------- 4 files changed, 36 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c index 04d7edb..bf4557c 100644 --- a/src/lexer/lexer.c +++ b/src/lexer/lexer.c @@ -132,11 +132,12 @@ t_token *push_token_enum_and_trim(t_token *lst_token) enum e_token_tag tk; tk = ret_token(lst_token->content, 0); + if (tk == 0) - { lst_token->tag = token_str_or_cote(lst_token); - } - //printf("%s-, %d\n",lst_token->content, (int)lst_token->tag); + else + lst_token->tag = tk; + //printf("%s-, %d\n",lst_token->content, lst_token->tag); return (lst_token); } diff --git a/src/main.c b/src/main.c index 14da075..b2d7143 100644 --- a/src/main.c +++ b/src/main.c @@ -120,7 +120,7 @@ int main(int argc, char **argv) ft_strlcpy(input, argv[1], ft_strlen(argv[1]) + 1); lst = lexer(input); - parse(lst); + //parse(lst); free(input); exit(0); return (0); diff --git a/src/parse/cmd_parse.c b/src/parse/cmd_parse.c index 78ce593..07070a1 100644 --- a/src/parse/cmd_parse.c +++ b/src/parse/cmd_parse.c @@ -1,3 +1,30 @@ #include "parser.h" + + +int parse_cmd_str_true_false(enum e_token_tag tag) +{ + if (tag & TAG_STR || tag & TAG_STR_DOUBLE || tag & TAG_STR_SINGLE) + return (1); + return(0); +} + + +t_ast *parse_cmd(t_ast *ast, t_ftlst *rest) +{ + t_ftlst *new; + + new = rest->data; + if (ast == NULL) + { + ast = ast_new(AST_CMD); + ast->cmd_argv = ft_lstnew((t_token *)rest->data); + } + else + { + new = ft_lstnew(rest->data); + ft_lstpush_back(&ast->cmd_argv, (void *)new); + } + return (ast); +} diff --git a/src/parse/parse.c b/src/parse/parse.c index a3e9526..4fc0aa7 100644 --- a/src/parse/parse.c +++ b/src/parse/parse.c @@ -8,31 +8,7 @@ // stdio.h est deja include dans minishell.h temporairement // (comme ca on doit le retirer a un seul endroit a la fin) -int parse_cmd_str_true_fale(enum e_token_tag tag) -{ - if (tag & TAG_STR || tag & TAG_STR_DOUBLE || tag & TAG_STR_SINGLE) - return (1); - return(0); -} - - -t_ast *parse_cmd(t_ast *ast, t_ftlst *rest) -{ - t_ftlst *new; - new = rest->data; - if (ast == NULL) - { - ast = ast_new(AST_CMD); - ast->cmd_argv = ft_lstnew((t_token *)rest->data); - } - else - { - new = ft_lstnew(rest->data); - ft_lstpush_back(&ast->cmd_argv, (void *)new); - } - return (ast); -} t_ret *parse(t_ftlst *input) { @@ -50,7 +26,10 @@ t_ret *parse(t_ftlst *input) while (ret->rest != NULL) { tag = ((t_token *)ret->rest->data)->tag; - if (parse_cmd_str_true_fale(tag)) + printf("%d\n", tag); + if (parse_redir_true_false(tag)) + ; + if (parse_cmd_str_true_false(tag)) ret->ast = parse_cmd(ret->ast, ret->rest); ret->rest = ret->rest->next; } -- cgit