aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/parser.h6
-rw-r--r--src/lexer/lexer.c7
-rw-r--r--src/main.c2
-rw-r--r--src/parse/cmd_parse.c27
-rw-r--r--src/parse/parse.c29
5 files changed, 37 insertions, 34 deletions
diff --git a/include/parser.h b/include/parser.h
index c81abee..099d4aa 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -40,10 +40,6 @@
t_ret *parse(t_ftlst *input);
t_ast *parse_cmd(t_ast *ast, t_ftlst *ret);
-
-/*
-** cmd_parse.c
-*/
-int parse_cmd_str_true_fale(enum e_token_tag tag);
+int parse_cmd_str_true_false(enum e_token_tag tag);
#endif
diff --git a/src/lexer/lexer.c b/src/lexer/lexer.c
index 04d7edb..bf4557c 100644
--- a/src/lexer/lexer.c
+++ b/src/lexer/lexer.c
@@ -132,11 +132,12 @@ t_token *push_token_enum_and_trim(t_token *lst_token)
enum e_token_tag tk;
tk = ret_token(lst_token->content, 0);
+
if (tk == 0)
- {
lst_token->tag = token_str_or_cote(lst_token);
- }
- //printf("%s-, %d\n",lst_token->content, (int)lst_token->tag);
+ else
+ lst_token->tag = tk;
+ //printf("%s-, %d\n",lst_token->content, lst_token->tag);
return (lst_token);
}
diff --git a/src/main.c b/src/main.c
index 14da075..b2d7143 100644
--- a/src/main.c
+++ b/src/main.c
@@ -120,7 +120,7 @@ int main(int argc, char **argv)
ft_strlcpy(input, argv[1], ft_strlen(argv[1]) + 1);
lst = lexer(input);
- parse(lst);
+ //parse(lst);
free(input);
exit(0);
return (0);
diff --git a/src/parse/cmd_parse.c b/src/parse/cmd_parse.c
index 78ce593..07070a1 100644
--- a/src/parse/cmd_parse.c
+++ b/src/parse/cmd_parse.c
@@ -1,3 +1,30 @@
#include "parser.h"
+
+
+int parse_cmd_str_true_false(enum e_token_tag tag)
+{
+ if (tag & TAG_STR || tag & TAG_STR_DOUBLE || tag & TAG_STR_SINGLE)
+ return (1);
+ return(0);
+}
+
+
+t_ast *parse_cmd(t_ast *ast, t_ftlst *rest)
+{
+ t_ftlst *new;
+
+ new = rest->data;
+ if (ast == NULL)
+ {
+ ast = ast_new(AST_CMD);
+ ast->cmd_argv = ft_lstnew((t_token *)rest->data);
+ }
+ else
+ {
+ new = ft_lstnew(rest->data);
+ ft_lstpush_back(&ast->cmd_argv, (void *)new);
+ }
+ return (ast);
+}
diff --git a/src/parse/parse.c b/src/parse/parse.c
index a3e9526..4fc0aa7 100644
--- a/src/parse/parse.c
+++ b/src/parse/parse.c
@@ -8,31 +8,7 @@
// stdio.h est deja include dans minishell.h temporairement
// (comme ca on doit le retirer a un seul endroit a la fin)
-int parse_cmd_str_true_fale(enum e_token_tag tag)
-{
- if (tag & TAG_STR || tag & TAG_STR_DOUBLE || tag & TAG_STR_SINGLE)
- return (1);
- return(0);
-}
-
-
-t_ast *parse_cmd(t_ast *ast, t_ftlst *rest)
-{
- t_ftlst *new;
- new = rest->data;
- if (ast == NULL)
- {
- ast = ast_new(AST_CMD);
- ast->cmd_argv = ft_lstnew((t_token *)rest->data);
- }
- else
- {
- new = ft_lstnew(rest->data);
- ft_lstpush_back(&ast->cmd_argv, (void *)new);
- }
- return (ast);
-}
t_ret *parse(t_ftlst *input)
{
@@ -50,7 +26,10 @@ t_ret *parse(t_ftlst *input)
while (ret->rest != NULL)
{
tag = ((t_token *)ret->rest->data)->tag;
- if (parse_cmd_str_true_fale(tag))
+ printf("%d\n", tag);
+ if (parse_redir_true_false(tag))
+ ;
+ if (parse_cmd_str_true_false(tag))
ret->ast = parse_cmd(ret->ast, ret->rest);
ret->rest = ret->rest->next;
}