diff --git a/42sh/file1 b/42sh/file1 new file mode 100644 index 00000000..ce09b016 --- /dev/null +++ b/42sh/file1 @@ -0,0 +1 @@ +/Users/ariard/Projects/42sh diff --git a/42sh/file2 b/42sh/file2 new file mode 100644 index 00000000..ce09b016 --- /dev/null +++ b/42sh/file2 @@ -0,0 +1 @@ +/Users/ariard/Projects/42sh diff --git a/42sh/includes/lexer.h b/42sh/includes/lexer.h index b29e1000..46500e7c 100644 --- a/42sh/includes/lexer.h +++ b/42sh/includes/lexer.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */ -/* Updated: 2017/01/26 21:29:07 by ariard ### ########.fr */ +/* Updated: 2017/01/27 12:49:53 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/sample/2lines.sh b/42sh/sample/2lines.sh index f598a168..b6efb7f2 100644 --- a/42sh/sample/2lines.sh +++ b/42sh/sample/2lines.sh @@ -1,2 +1,3 @@ -ls | cat -pwd | cat +ls ; echo ; pwd | cat > file2 +ls | cat +pwd > file1 diff --git a/42sh/src/builtin/builtin_cd.c b/42sh/src/builtin/builtin_cd.c index 6c84c1db..7be11cca 100644 --- a/42sh/src/builtin/builtin_cd.c +++ b/42sh/src/builtin/builtin_cd.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 11:57:53 by jhalford #+# #+# */ -/* Updated: 2017/01/20 00:10:52 by ariard ### ########.fr */ +/* Updated: 2017/01/27 15:12:12 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/ft_tokenize.c b/42sh/src/lexer/ft_tokenize.c index c34db1e3..cff6e516 100644 --- a/42sh/src/lexer/ft_tokenize.c +++ b/42sh/src/lexer/ft_tokenize.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */ -/* Updated: 2017/01/26 22:27:16 by ariard ### ########.fr */ +/* Updated: 2017/01/27 12:50:21 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/get_lexer_state.c b/42sh/src/lexer/get_lexer_state.c index 08d730bd..3fceeeb0 100644 --- a/42sh/src/lexer/get_lexer_state.c +++ b/42sh/src/lexer/get_lexer_state.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/10 13:45:46 by jhalford #+# #+# */ -/* Updated: 2017/01/26 00:31:25 by ariard ### ########.fr */ +/* Updated: 2017/01/27 12:49:24 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_delim.c b/42sh/src/lexer/lexer_delim.c index 8f05a9bb..74947d16 100644 --- a/42sh/src/lexer/lexer_delim.c +++ b/42sh/src/lexer/lexer_delim.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 11:58:44 by jhalford #+# #+# */ -/* Updated: 2017/01/26 00:08:33 by ariard ### ########.fr */ +/* Updated: 2017/01/26 23:37:49 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_newline.c b/42sh/src/lexer/lexer_newline.c index 0a98df66..dc3b830f 100644 --- a/42sh/src/lexer/lexer_newline.c +++ b/42sh/src/lexer/lexer_newline.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/23 23:19:46 by ariard #+# #+# */ -/* Updated: 2017/01/26 00:41:18 by ariard ### ########.fr */ +/* Updated: 2017/01/27 12:51:12 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_word.c b/42sh/src/lexer/lexer_word.c index 44ab926c..9f2fab64 100644 --- a/42sh/src/lexer/lexer_word.c +++ b/42sh/src/lexer/lexer_word.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 12:07:11 by jhalford #+# #+# */ -/* Updated: 2017/01/26 18:25:53 by ariard ### ########.fr */ +/* Updated: 2017/01/27 12:51:00 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/token_init.c b/42sh/src/lexer/token_init.c index fcd796c5..1cae40d0 100644 --- a/42sh/src/lexer/token_init.c +++ b/42sh/src/lexer/token_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 15:30:25 by jhalford #+# #+# */ -/* Updated: 2017/01/24 01:07:41 by ariard ### ########.fr */ +/* Updated: 2017/01/26 23:36:55 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,6 +17,7 @@ t_token *token_init(void) t_token *token; token = (t_token *)malloc(sizeof(t_token)); +//non protege token->type = 0; token->size = 10; token->data = ft_strnew(token->size); diff --git a/42sh/src/main/shell_script.c b/42sh/src/main/shell_script.c index 35627524..7cf6cddd 100644 --- a/42sh/src/main/shell_script.c +++ b/42sh/src/main/shell_script.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/22 23:06:34 by ariard #+# #+# */ -/* Updated: 2017/01/26 22:42:07 by ariard ### ########.fr */ +/* Updated: 2017/01/28 23:38:10 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ int shell_script() { t_list *token; t_btree *ast; + t_btree **ast2; t_list *list_ast; t_list *tmp2; @@ -34,15 +35,14 @@ int shell_script() return (1); tmp2 = list_ast; while (tmp2) - { - btree_print(STDBUG, tmp2->content, &ft_putast); + { + ast2 = tmp2->content; + btree_print(STDBUG, *ast2, &ft_putast); tmp2 = tmp2->next; } - return (0); while (list_ast) { - ast = list_ast->content; - if (ft_exec(&ast)) + if (ft_exec((t_btree **)list_ast->content)) return (1); list_ast = list_ast->next; } diff --git a/42sh/src/parser/.ft_parse.c.swn b/42sh/src/parser/.ft_parse.c.swn new file mode 100644 index 00000000..3c43bc8b Binary files /dev/null and b/42sh/src/parser/.ft_parse.c.swn differ diff --git a/42sh/src/parser/ft_parse.c b/42sh/src/parser/ft_parse.c index ece898bd..a9e6bc0a 100644 --- a/42sh/src/parser/ft_parse.c +++ b/42sh/src/parser/ft_parse.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */ -/* Updated: 2017/01/26 22:42:09 by ariard ### ########.fr */ +/* Updated: 2017/01/28 23:27:39 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,8 +44,8 @@ int ft_parse(t_list **list_ast, t_btree **ast, t_list **start) *ast = btree_create_node(&item, sizeof(item)); ((t_astnode *)(*ast)->item)->data.sstr = NULL; } -// if (!*list_ast) -// ft_lsteadd(list_ast, ft_lstnew(ast, sizeof(*ast))); + if (!*list_ast) + *list_ast = ft_lstnew(ast, sizeof(t_btree *)); while (g_parser[i].type) { if ((lst = ft_lst_find(*start, &g_parser[i].type, &token_cmp_type))) diff --git a/42sh/src/parser/parse_newline.c b/42sh/src/parser/parse_newline.c index c4ed9ff2..84b48aa5 100644 --- a/42sh/src/parser/parse_newline.c +++ b/42sh/src/parser/parse_newline.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 19:26:41 by ariard #+# #+# */ -/* Updated: 2017/01/26 22:39:50 by ariard ### ########.fr */ +/* Updated: 2017/01/28 23:24:40 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,14 +16,13 @@ int parse_newline(t_list **list_ast, t_btree **ast, t_list **start, t_list **lst) { t_list *temp; - - ft_putstr("newline"); + + DG("parsing newline"); temp = (*lst)->next; (*lst)->next = NULL; ft_lst_delif(start, (*lst)->content, &ft_addrcmp, &token_free); - *lst = NULL; ft_parse(list_ast, ast, start); *ast = NULL; - ft_parse(list_ast, ast, &temp); + ft_parse(&(*list_ast)->next, ast, &temp); return (0); } diff --git a/42sh/src/parser/parse_separator.c b/42sh/src/parser/parse_separator.c index 3737f4b5..783c974c 100644 --- a/42sh/src/parser/parse_separator.c +++ b/42sh/src/parser/parse_separator.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 16:21:51 by jhalford #+# #+# */ -/* Updated: 2017/01/26 22:42:17 by ariard ### ########.fr */ +/* Updated: 2017/01/28 23:01:44 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,7 @@ int parse_separator(t_list **list_ast, t_btree **ast, t_token *token; t_astnode *node; + DG("parsing separator"); token = (*lst)->content; node = (*ast)->item; node->type = token->type; diff --git a/42sh/src/parser/parse_word.c b/42sh/src/parser/parse_word.c index fe49f4c2..84dffdb2 100644 --- a/42sh/src/parser/parse_word.c +++ b/42sh/src/parser/parse_word.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 12:49:45 by jhalford #+# #+# */ -/* Updated: 2017/01/26 22:37:26 by ariard ### ########.fr */ +/* Updated: 2017/01/27 13:52:59 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,6 @@ int parse_word(t_list **list_ast, t_btree **ast, t_astnode *node; t_token *token; - ft_putstr("word"); (void)start; (void)list_ast; token = (*lst)->content;