syntax analysis with simplified shell grammar

+ TODO : bug to fix in lexer.c
This commit is contained in:
LuckyLaszlo
2021-10-24 19:58:19 +02:00
parent 906074d2cb
commit 815cedb8ca
11 changed files with 400 additions and 18 deletions

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/04 05:59:26 by lperrey #+# #+# */
/* Updated: 2021/10/22 10:48:07 by lperrey ### ########.fr */
/* Updated: 2021/10/24 19:17:03 by lperrey ### ########.fr */
/* */
/* ************************************************************************** */
@@ -28,17 +28,23 @@ void shell_loop(t_all *c)
{
add_history(line_input);
c->token_list = input_to_tokens(line_input);
c->token_list = input_to_tokens(line_input);
// EXEC_PIPES_AND_CO()
// temp placeholder
if (!ft_strncmp(c->token_list->content, "env", 4))
if (ft_strncmp(c->token_list->content, "env", 4) == 0)
builtin_env(0, NULL, c);
else if (!ft_strncmp(c->token_list->content, "exit", 5))
else if (ft_strncmp(c->token_list->content, "exit", 5) == 0)
builtin_exit(0, NULL, c);
else if (!ft_strncmp(c->token_list->content, "echo", 5))
else if (ft_strncmp(c->token_list->content, "echo", 5) == 0)
builtin_echo(ft_lstsize((t_list *)c->token_list) + 1, tokens_list_to_argv(c->token_list), c);
else
{
if (parsing(c->token_list))
ft_putstr_fd("Syntax OK:\n-----------\n", 1);
else
ft_putstr_fd("Syntax KO:\n-----------\n", 1);
ft_putstr_fd("TOKENS LIST :\n-----------\n", 1);
ft_lstprint((t_list *)c->token_list, 1);
ft_lstclear((t_list **)&c->token_list, free);