before rebase
This commit is contained in:
parent
f33d2be526
commit
36dcd432a4
15 changed files with 61 additions and 82 deletions
|
|
@ -1,20 +1,11 @@
|
|||
echo "begin loop"
|
||||
while [ 1 ]
|
||||
do
|
||||
echo "inner loop1"
|
||||
while [ 1 ]
|
||||
do
|
||||
echo "begin inner loop"
|
||||
while [ 1 ]
|
||||
do
|
||||
echo "love 42"
|
||||
echo "end scd loop"
|
||||
done
|
||||
echo "inner loop2"
|
||||
while [ 1 ]
|
||||
do
|
||||
echo "inner loop2-1"
|
||||
while [ 1 ]
|
||||
do
|
||||
echo "hello world"
|
||||
done
|
||||
echo "salut monde"
|
||||
done
|
||||
done
|
||||
echo "end inner loop"
|
||||
done
|
||||
echo "end loop"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/30 23:25:44 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 17:25:52 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -38,7 +38,6 @@ int exec_command(t_btree **ast)
|
|||
p->pid = 0;
|
||||
p->attributes = PROCESS_PIPESTART | PROCESS_PIPEEND;
|
||||
|
||||
if (!(p->script & SCRIPT_LOOP))
|
||||
btree_delone(ast, &ast_free);
|
||||
// btree_delone(ast, &ast_free);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/31 19:29:59 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/31 19:57:44 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 15:54:31 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,10 +14,8 @@
|
|||
|
||||
int exec_default(t_btree **ast)
|
||||
{
|
||||
t_process *p;
|
||||
|
||||
p = &data_singleton()->exec.process;
|
||||
if (!(p->script & SCRIPT_LOOP))
|
||||
btree_delone(ast, &ast_free);
|
||||
|
||||
(void)ast;
|
||||
// btree_delone(ast, &ast_free);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/30 20:19:29 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/30 20:57:51 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 16:00:40 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,10 +14,7 @@
|
|||
|
||||
int exec_list(t_btree **ast)
|
||||
{
|
||||
t_process *p;
|
||||
|
||||
p = &data_singleton()->exec.process;
|
||||
if (!(p->script & SCRIPT_LOOP))
|
||||
btree_delone(ast, &ast_free);
|
||||
(void)ast;
|
||||
// btree_delone(ast, &ast_free);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/30 17:33:53 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/31 23:20:33 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 16:30:05 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,30 +14,23 @@
|
|||
|
||||
int exec_while(t_btree **ast)
|
||||
{
|
||||
t_list **test_commands;
|
||||
t_list **consequent_commands;
|
||||
t_astnode *node;
|
||||
t_process *p;
|
||||
int test;
|
||||
|
||||
node = ((*ast)->left)->item;
|
||||
DG("test command data '%s'", node->data.str);
|
||||
test_commands = shell_get_ast(node->data.str);
|
||||
node = ((*ast)->right)->item;
|
||||
|
||||
DG("consequent command data '%s'", node->data.str);
|
||||
consequent_commands = shell_get_ast(node->data.str);
|
||||
|
||||
p = &data_singleton()->exec.process;
|
||||
p->script |= SCRIPT_LOOP;
|
||||
|
||||
|
||||
|
||||
test = 10;
|
||||
while (test--)
|
||||
{
|
||||
loop_exec(*consequent_commands);
|
||||
loop_del(*consequent_commands);
|
||||
p->script &= 0;
|
||||
btree_delone(ast, &ast_free);
|
||||
DG("end loop : '%d'", test);
|
||||
}
|
||||
|
||||
// loop_del(*consequent_commands);
|
||||
// btree_delone(ast, &ast_free);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/11 16:11:11 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/22 23:33:04 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 17:50:45 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,6 +16,7 @@ int ft_post_tokenize(t_list **alst, char *str)
|
|||
{
|
||||
int ret;
|
||||
|
||||
// get_reserverd_words(alst, str);
|
||||
while ((ret = reduce_parens(alst, str)))
|
||||
if (ret == -1)
|
||||
return (-1);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/31 23:58:41 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 17:50:28 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -29,13 +29,6 @@ int (*g_lexer[])(t_list **alst, char *str) =
|
|||
&lexer_backslash,
|
||||
&lexer_var,
|
||||
&lexer_special,
|
||||
&lexer_while,
|
||||
&lexer_do,
|
||||
&lexer_done,
|
||||
&lexer_if,
|
||||
&lexer_then,
|
||||
&lexer_fi,
|
||||
&lexer_list,
|
||||
&lexer_comment,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,25 +6,35 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/26 00:07:05 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/31 23:51:56 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 17:50:17 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "lexer.h"
|
||||
|
||||
t_lexstate get_reserved_words(char *str)
|
||||
int get_reserved_words(t_list **alst)
|
||||
{
|
||||
if (ft_strncmp(str, "while", 5) == 0)
|
||||
return (WHILE);
|
||||
else if (ft_strncmp(str, "done", 4) == 0 && ft_isalpha(*(str + 4)) == 0)
|
||||
return (DONE);
|
||||
else if (ft_strncmp(str, "do" , 2) == 0 && ft_isalpha(*(str + 2)) == 0)
|
||||
return (DO);
|
||||
else if (ft_strncmp(str, "if", 2) == 0 && ft_isalpha(*(str + 2)) == 0)
|
||||
return (IF);
|
||||
else if (ft_strncmp(str, "then", 4) == 0 && ft_isalpha(*(str + 4)) == 0)
|
||||
return (THEN);
|
||||
else if (ft_strncmp(str, "fi", 2) == 0 && ft_isalpha(*(str + 2)) == 0)
|
||||
return (FI);
|
||||
t_token token;
|
||||
|
||||
while (*alst)
|
||||
{
|
||||
token = (*alst)->content;
|
||||
if (token->type = TK_WORD);
|
||||
{
|
||||
if (ft_strncmp(str, "while", 5) == 0 && ft_isalpha(*(str + 5)) == 0)
|
||||
lexer_while(
|
||||
else if (ft_strncmp(str, "done", 4) == 0 && ft_isalpha(*(str + 4)) == 0)
|
||||
return (DONE);
|
||||
else if (ft_strncmp(str, "do" , 2) == 0 && ft_isalpha(*(str + 2)) == 0)
|
||||
return (DO);
|
||||
// else if (ft_strncmp(str, "if", 2) == 0 && ft_isalpha(*(str + 2)) == 0)
|
||||
// return (IF);
|
||||
// else if (ft_strncmp(str, "then", 4) == 0 && ft_isalpha(*(str + 4)) == 0)
|
||||
// return (THEN);
|
||||
// else if (ft_strncmp(str, "fi", 2) == 0 && ft_isalpha(*(str + 2)) == 0)
|
||||
// return (FI);
|
||||
}
|
||||
(*alst) = (*alst)->next;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/26 00:55:33 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/31 23:58:50 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 17:31:07 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -25,8 +25,7 @@ int lexer_list(t_list **alst, char *str)
|
|||
token_append(token, *str++);
|
||||
while (ft_is_delim(*str) || *str == '\n')
|
||||
str++;
|
||||
if (ft_strncmp(str, "done", 4) == 0 && (ft_is_delim_list(*(str + 4))
|
||||
|| *(str + 4) == ' '))
|
||||
if (ft_strncmp(str, "done", 4) == 0 && ft_isalpha(*(str + 4)) == 0)
|
||||
return (ft_tokenize(alst, str, DONE));
|
||||
else if (ft_strncmp(str, "do", 2) == 0 && (ft_is_delim_list(*(str + 2))
|
||||
|| *(str + 2) == ' '))
|
||||
|
|
@ -34,8 +33,7 @@ int lexer_list(t_list **alst, char *str)
|
|||
else if (ft_strncmp(str, "then", 4) == 0 && (ft_is_delim_list(*(str + 4))
|
||||
|| *(str + 4) == ' '))
|
||||
return (ft_tokenize(alst, str, THEN));
|
||||
else if (ft_strncmp(str, "fi", 2) == 0 && (ft_is_delim_list(*(str + 2))
|
||||
|| *(str + 2) == ' '))
|
||||
else if (ft_strncmp(str, "fi", 2) == 0 && ft_isalpha(*(str + 2)) == 0)
|
||||
return (ft_tokenize(alst, str, FI));
|
||||
}
|
||||
token_append(token, *str++);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/30 16:29:57 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/26 00:48:08 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 16:30:03 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/03 12:07:11 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/30 23:17:43 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 17:50:27 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -25,8 +25,6 @@ int lexer_word(t_list **alst, char *str)
|
|||
return (ft_tokenize(&(*alst)->next, str, GREAT));
|
||||
else if (*str == '<')
|
||||
return (ft_tokenize(&(*alst)->next, str, LESS));
|
||||
else if ((state = get_reserved_words(str)))
|
||||
return (ft_tokenize(alst, str, state));
|
||||
token_append(token, *str);
|
||||
return (ft_tokenize(alst, str + 1, WORD));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/11 16:46:27 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/22 23:33:08 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 17:40:29 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/22 23:06:34 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/31 23:56:53 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 17:50:21 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -31,7 +31,6 @@ int shell_script()
|
|||
return (1);
|
||||
DG("after post_tokenize");
|
||||
token_print(token);
|
||||
return (0);
|
||||
if (ft_parse(&list_ast, &ast, &token))
|
||||
return (1);
|
||||
tmp2 = list_ast;
|
||||
|
|
@ -47,6 +46,8 @@ int shell_script()
|
|||
return (1);
|
||||
list_ast = list_ast->next;
|
||||
}
|
||||
*/ loop_exec(list_ast);
|
||||
|
||||
*/
|
||||
loop_exec(list_ast);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/30 16:36:28 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/31 19:36:49 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 16:44:47 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/30 16:03:28 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/30 19:52:17 by ariard ### ########.fr */
|
||||
/* Updated: 2017/02/02 16:30:35 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue