generation liste chainee d'ast de multi commande ok, to-do : ast de while
This commit is contained in:
parent
47a2fdd683
commit
42bd66af42
17 changed files with 30 additions and 27 deletions
1
42sh/file1
Normal file
1
42sh/file1
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/Users/ariard/Projects/42sh
|
||||||
1
42sh/file2
Normal file
1
42sh/file2
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/Users/ariard/Projects/42sh
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/01 12:15:50 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
ls ; echo ; pwd | cat > file2
|
||||||
ls | cat
|
ls | cat
|
||||||
pwd | cat
|
pwd > file1
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 11:57:53 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/10 13:37:11 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/10 13:45:46 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 11:58:44 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/23 23:19:46 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:07:11 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/10 15:30:25 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;
|
t_token *token;
|
||||||
|
|
||||||
token = (t_token *)malloc(sizeof(t_token));
|
token = (t_token *)malloc(sizeof(t_token));
|
||||||
|
//non protege
|
||||||
token->type = 0;
|
token->type = 0;
|
||||||
token->size = 10;
|
token->size = 10;
|
||||||
token->data = ft_strnew(token->size);
|
token->data = ft_strnew(token->size);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/22 23:06:34 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_list *token;
|
||||||
t_btree *ast;
|
t_btree *ast;
|
||||||
|
t_btree **ast2;
|
||||||
t_list *list_ast;
|
t_list *list_ast;
|
||||||
t_list *tmp2;
|
t_list *tmp2;
|
||||||
|
|
||||||
|
|
@ -35,14 +36,13 @@ int shell_script()
|
||||||
tmp2 = list_ast;
|
tmp2 = list_ast;
|
||||||
while (tmp2)
|
while (tmp2)
|
||||||
{
|
{
|
||||||
btree_print(STDBUG, tmp2->content, &ft_putast);
|
ast2 = tmp2->content;
|
||||||
|
btree_print(STDBUG, *ast2, &ft_putast);
|
||||||
tmp2 = tmp2->next;
|
tmp2 = tmp2->next;
|
||||||
}
|
}
|
||||||
return (0);
|
|
||||||
while (list_ast)
|
while (list_ast)
|
||||||
{
|
{
|
||||||
ast = list_ast->content;
|
if (ft_exec((t_btree **)list_ast->content))
|
||||||
if (ft_exec(&ast))
|
|
||||||
return (1);
|
return (1);
|
||||||
list_ast = list_ast->next;
|
list_ast = list_ast->next;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
42sh/src/parser/.ft_parse.c.swn
Normal file
BIN
42sh/src/parser/.ft_parse.c.swn
Normal file
Binary file not shown.
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/30 17:14:58 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));
|
*ast = btree_create_node(&item, sizeof(item));
|
||||||
((t_astnode *)(*ast)->item)->data.sstr = NULL;
|
((t_astnode *)(*ast)->item)->data.sstr = NULL;
|
||||||
}
|
}
|
||||||
// if (!*list_ast)
|
if (!*list_ast)
|
||||||
// ft_lsteadd(list_ast, ft_lstnew(ast, sizeof(*ast)));
|
*list_ast = ft_lstnew(ast, sizeof(t_btree *));
|
||||||
while (g_parser[i].type)
|
while (g_parser[i].type)
|
||||||
{
|
{
|
||||||
if ((lst = ft_lst_find(*start, &g_parser[i].type, &token_cmp_type)))
|
if ((lst = ft_lst_find(*start, &g_parser[i].type, &token_cmp_type)))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/26 19:26:41 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,13 +17,12 @@ int parse_newline(t_list **list_ast, t_btree **ast,
|
||||||
{
|
{
|
||||||
t_list *temp;
|
t_list *temp;
|
||||||
|
|
||||||
ft_putstr("newline");
|
DG("parsing newline");
|
||||||
temp = (*lst)->next;
|
temp = (*lst)->next;
|
||||||
(*lst)->next = NULL;
|
(*lst)->next = NULL;
|
||||||
ft_lst_delif(start, (*lst)->content, &ft_addrcmp, &token_free);
|
ft_lst_delif(start, (*lst)->content, &ft_addrcmp, &token_free);
|
||||||
*lst = NULL;
|
|
||||||
ft_parse(list_ast, ast, start);
|
ft_parse(list_ast, ast, start);
|
||||||
*ast = NULL;
|
*ast = NULL;
|
||||||
ft_parse(list_ast, ast, &temp);
|
ft_parse(&(*list_ast)->next, ast, &temp);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 16:21:51 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_token *token;
|
||||||
t_astnode *node;
|
t_astnode *node;
|
||||||
|
|
||||||
|
DG("parsing separator");
|
||||||
token = (*lst)->content;
|
token = (*lst)->content;
|
||||||
node = (*ast)->item;
|
node = (*ast)->item;
|
||||||
node->type = token->type;
|
node->type = token->type;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/14 12:49:45 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_astnode *node;
|
||||||
t_token *token;
|
t_token *token;
|
||||||
|
|
||||||
ft_putstr("word");
|
|
||||||
(void)start;
|
(void)start;
|
||||||
(void)list_ast;
|
(void)list_ast;
|
||||||
token = (*lst)->content;
|
token = (*lst)->content;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue