aboutsummaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authornass1pro <nass1pro@gmail.com>2020-06-15 17:43:03 +0200
committernass1pro <nass1pro@gmail.com>2020-06-15 17:43:03 +0200
commitb72b43e5715424f01626f31f74f0c0d83d7bfb24 (patch)
treeac0d0a402407809520230d7fd31184beedf3f70f /src/parse
parentc64a7a8fca764c1f0fe8e4a8e28526e1de49f707 (diff)
downloadminishell-b72b43e5715424f01626f31f74f0c0d83d7bfb24.tar.gz
minishell-b72b43e5715424f01626f31f74f0c0d83d7bfb24.tar.bz2
minishell-b72b43e5715424f01626f31f74f0c0d83d7bfb24.zip
Change name function parse
Diffstat (limited to 'src/parse')
-rwxr-xr-xsrc/parse/cmd_parse.c2
-rwxr-xr-xsrc/parse/parse.c48
-rwxr-xr-xsrc/parse/redir_parse.c2
3 files changed, 22 insertions, 30 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 87478ac..b9cc514 100755
--- a/src/parse/parse.c
+++ b/src/parse/parse.c
@@ -30,6 +30,8 @@ t_ret *parse(t_ftlst *input)
if (parse_cmd_str_true_false(tag))
{
ret->ast = parse_cmd(ret->ast, ret->rest);
+ if (ret->rest != NULL)
+ ret->rest = ret->rest->next;
}
else if (parse_redir_true_false(tag))
{
@@ -37,35 +39,25 @@ t_ret *parse(t_ftlst *input)
ret->rest = ret->rest->next;
if (ret->rest != NULL)
ret->ast = parse_redir(ret->ast, ret->rest);
- /* printf("%s\n","ici" ); */
- ret->rest = ret->rest->next;
- if (ret->rest != NULL)
- {
- tag = ((t_token *)ret->rest->data)->tag;
- if(tag & TAG_IS_STR & TAG_STICK)
- ret->ast = parse_redir(ret->ast, ret->rest);
- }
+ tag = ((t_token *)ret->rest->data)->tag;
+ //while(tag & TAG_IS_STR && tag & TAG_STICK)
}
- 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)
+ {
+ if (i == 0)
+ {
+ 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);
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;