aboutsummaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse')
-rwxr-xr-xsrc/parse/cmd_parse.c2
-rwxr-xr-xsrc/parse/parse.c52
-rwxr-xr-xsrc/parse/redir_parse.c2
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;