diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 12 | ||||
| -rwxr-xr-x | src/parse/cmd_parse.c | 2 | ||||
| -rwxr-xr-x | src/parse/parse.c | 48 | ||||
| -rwxr-xr-x | src/parse/redir_parse.c | 2 |
4 files changed, 28 insertions, 36 deletions
@@ -26,7 +26,7 @@ void token_debug(void *v) t_token *t; t= v; - printf("[%4d] (%s)\n", t->tag, t->content); + //printf("[%4d] (%s)\n", t->tag, t->content); } int main(int argc, char **argv, char **envp) @@ -46,13 +46,13 @@ int main(int argc, char **argv, char **envp) t_ret *parser_out = parse(lex_out); - printf("%p\n", parser_out->ast->cmd_argv); - printf("%p\n", parser_out->ast->redirs); + // printf("%s\n", ((t_token *)parser_out->ast->cmd_argv->data)->content); + // printf("%s\n", ((t_token *)parser_out->ast->redirs->data)->content); - /* ft_lstiter(parser_out->ast->cmd_argv, token_debug); */ + //ft_lstiter(parser_out->ast->cmd_argv, token_debug); - int eval_out = eval_cmd(env, path, parser_out->ast); - (void)eval_out; + //int eval_out = eval_cmd(env, path, parser_out->ast); + // (void)eval_out; } ft_htdestroy(path, free); 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; |
