aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/parser.h4
-rw-r--r--salut1
-rw-r--r--src/main.c12
-rwxr-xr-xsrc/parse/cmd_parse.c2
-rwxr-xr-xsrc/parse/parse.c48
-rwxr-xr-xsrc/parse/redir_parse.c2
6 files changed, 31 insertions, 38 deletions
diff --git a/include/parser.h b/include/parser.h
index 2e6bae1..2bfa9d5 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -38,8 +38,8 @@
*/
t_ret *parse(t_ftlst *input);
-t_ast *parse_cmd(t_ast *ast, t_ftlst *ret);
-t_ast *parse_redir(t_ast *ast, t_ftlst *rest);
+t_ast *push_cmd(t_ast *ast, t_ftlst *ret);
+t_ast *push_redir(t_ast *ast, t_ftlst *rest);
int parse_cmd_str_true_false(enum e_token_tag tag);
int parse_redir_true_false(enum e_token_tag tag);
diff --git a/salut b/salut
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/salut
@@ -0,0 +1 @@
+
diff --git a/src/main.c b/src/main.c
index 3bbc58b..1d30270 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;