diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-06-16 10:10:48 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-06-16 10:11:58 +0200 |
| commit | 46c33fbad5e4965d2d56579e0ce6a97f310b3019 (patch) | |
| tree | 09180cccae5b8e2628dd6f36461db99ae4ddbc0d /src/parse | |
| parent | 28ab60062e26347cb1f28dfea63dbd8090252e4d (diff) | |
| parent | 25ba3ac2ccef9ba8295c3975a1681baa033c5ee6 (diff) | |
| download | minishell-46c33fbad5e4965d2d56579e0ce6a97f310b3019.tar.gz minishell-46c33fbad5e4965d2d56579e0ce6a97f310b3019.tar.bz2 minishell-46c33fbad5e4965d2d56579e0ce6a97f310b3019.zip | |
Merge branch 'parse_cmd' into eval
Diffstat (limited to 'src/parse')
| -rwxr-xr-x | src/parse/cmd_parse.c | 2 | ||||
| -rwxr-xr-x | src/parse/parse.c | 52 | ||||
| -rwxr-xr-x | src/parse/redir_parse.c | 2 |
3 files changed, 24 insertions, 32 deletions
diff --git a/src/parse/cmd_parse.c b/src/parse/cmd_parse.c index 8b52d0a..c655c5c 100755 --- a/src/parse/cmd_parse.c +++ b/src/parse/cmd_parse.c @@ -11,7 +11,7 @@ int parse_cmd_str_true_false(enum e_token_tag tag) } -t_ast *parse_cmd(t_ast *ast, t_ftlst *rest) +t_ast *push_cmd(t_ast *ast, t_ftlst *rest) { t_ftlst *new; diff --git a/src/parse/parse.c b/src/parse/parse.c index f2c4632..1129696 100755 --- a/src/parse/parse.c +++ b/src/parse/parse.c @@ -15,7 +15,6 @@ t_ret *parse(t_ftlst *input) t_ret *ret; t_ret *first; enum e_token_tag tag; - /* int i = 0; */ if(!(ret = malloc(sizeof(t_ret) * 1))) return(NULL); @@ -29,43 +28,36 @@ t_ret *parse(t_ftlst *input) tag = ((t_token *)ret->rest->data)->tag; if (parse_cmd_str_true_false(tag)) { - ret->ast = parse_cmd(ret->ast, ret->rest); + ret->ast = push_cmd(ret->ast, ret->rest); + if (ret->rest != NULL) + ret->rest = ret->rest->next; } else if (parse_redir_true_false(tag)) { - ret->ast = parse_redir(ret->ast, ret->rest); - ret->rest = ret->rest->next; - if (ret->rest != NULL) - ret->ast = parse_redir(ret->ast, ret->rest); - /* printf("%s\n","ici" ); */ + ret->ast = push_redir(ret->ast, ret->rest); ret->rest = ret->rest->next; - if (ret->rest != NULL) + while(ret->rest != NULL) { + ret->ast = push_redir(ret->ast, ret->rest); tag = ((t_token *)ret->rest->data)->tag; - if ((tag & TAG_IS_STR) && (tag & TAG_STICK)) - ret->ast = parse_redir(ret->ast, ret->rest); + if (tag & TAG_IS_STR && tag & TAG_STICK) + ret->rest = ret->rest->next; + else + break; } } - if (ret->rest != NULL) - ret->rest = ret->rest->next; } - - /* while(ret->ast->cmd_argv != NULL) */ - /* { */ - /* printf("%s\n", ((t_token *)ret->ast->cmd_argv->data)->content); */ - /* ret->ast->cmd_argv = ret->ast->cmd_argv->next; */ - /* } */ - /* while(ret->ast->redirs != NULL) */ - /* { */ - /* if (i == 0) */ - /* { */ - /* printf("redir"); */ - /* i++; */ - /* } */ - /* printf("%s\n", ((t_token *)ret->ast->redirs->data)->content); */ - /* ret->ast->redirs = ret->ast->redirs->next; */ - /* } */ - /* ast_destroy(ret->ast); */ - /* ft_lstdestroy(&ret->rest, (void (*)(void*))token_destroy); */ + // while(ret->ast->cmd_argv != NULL) + // { + // printf("%s\n", ((t_token *)ret->ast->cmd_argv->data)->content); + // ret->ast->cmd_argv = ret->ast->cmd_argv->next; + // } + // while(ret->ast->redirs != NULL) + // { + // printf("%s\n", ((t_token *)ret->ast->redirs->data)->content); + // ret->ast->redirs = ret->ast->redirs->next; + // } + // ast_destroy(ret->ast); + // ft_lstdestroy(&ret->rest, (void (*)(void*))token_destroy); return first; } diff --git a/src/parse/redir_parse.c b/src/parse/redir_parse.c index c92d639..839e37c 100755 --- a/src/parse/redir_parse.c +++ b/src/parse/redir_parse.c @@ -8,7 +8,7 @@ int parse_redir_true_false(enum e_token_tag tag) return (0); } -t_ast *parse_redir(t_ast *ast, t_ftlst *rest) +t_ast *push_redir(t_ast *ast, t_ftlst *rest) { t_ftlst *new; |
