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/parse/cmd_parse.c | 27 +++++++++++++++++++++++++++ src/parse/parse.c | 29 ++++------------------------- 2 files changed, 31 insertions(+), 25 deletions(-) (limited to 'src/parse') 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