comment same bug that with a space in input execution, tree empty cause bug execution
This commit is contained in:
parent
c1c3d73b17
commit
a011f94bcb
25 changed files with 63 additions and 32 deletions
1
42sh/file1
Normal file
1
42sh/file1
Normal file
|
|
@ -0,0 +1 @@
|
|||
0
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/22 22:42:30 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 20:01:46 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/24 16:21:11 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 20:13:54 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -62,6 +62,7 @@ enum e_lexstate
|
|||
BACKSLASH,
|
||||
VAR,
|
||||
SPECIAL,
|
||||
COMMENT,
|
||||
};
|
||||
|
||||
struct s_token
|
||||
|
|
@ -94,6 +95,7 @@ int ft_is_delim(char c);
|
|||
|
||||
t_lexstate get_lexer_state(char *str);
|
||||
int lexer_default(t_list **alst, char *str);
|
||||
int lexer_comment(t_list **alst, char *str);
|
||||
int lexer_newline(t_list **alst, char *str);
|
||||
int lexer_delim(t_list **alst, char *str);
|
||||
int lexer_sep(t_list **alst, char *str);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/24 16:35:43 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 20:04:55 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/01 12:15:54 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/24 16:46:36 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 20:08:01 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
ls | wc -l > file1
|
||||
cd ; ls
|
||||
ls | wc -l > file1 ; cd
|
||||
pwd ; echo "hello world"
|
||||
|
|
|
|||
4
42sh/sample/4lines.sh
Normal file
4
42sh/sample/4lines.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ls | wc -l > file1
|
||||
cd ; pwd | wc -l ; echo "bonjour"
|
||||
ls -l > file2
|
||||
pwd ; echo "hello world"
|
||||
2
42sh/sample/comment.sh
Normal file
2
42sh/sample/comment.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
ls #ls
|
||||
pwd
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ sh exitzero.sh ]
|
||||
then
|
||||
echo "hello world"
|
||||
fi
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
ls
|
||||
exit (0)
|
||||
1
42sh/sample/file1
Normal file
1
42sh/sample/file1
Normal file
|
|
@ -0,0 +1 @@
|
|||
0
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/22 22:08:22 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 20:03:01 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/24 17:54:08 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 20:13:42 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -29,6 +29,7 @@ int (*g_lexer[])(t_list **alst, char *str) =
|
|||
&lexer_backslash,
|
||||
&lexer_var,
|
||||
&lexer_special,
|
||||
&lexer_comment,
|
||||
};
|
||||
|
||||
int ft_is_delim(char c)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/10 13:45:46 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/24 00:55:05 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 19:09:26 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
24
42sh/src/lexer/lexer_comment.c
Normal file
24
42sh/src/lexer/lexer_comment.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* lexer_comment.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/24 18:22:35 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/24 20:07:14 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "lexer.h"
|
||||
|
||||
int lexer_comment(t_list **alst, char *str)
|
||||
{
|
||||
t_token *token;
|
||||
|
||||
(void)str;
|
||||
token = (*alst)->content;
|
||||
if (!token->type)
|
||||
ft_lstdel(alst, &token_free);
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 18:36:21 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/24 01:01:43 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 19:22:58 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -23,6 +23,8 @@ int lexer_default(t_list **alst, char *str)
|
|||
return (ft_tokenize(alst, str, GREAT));
|
||||
else if (*str == '<')
|
||||
return (ft_tokenize(alst, str, LESS));
|
||||
else if (*str == '#')
|
||||
return (ft_tokenize(alst, str, COMMENT));
|
||||
else if (ft_isdigit(*str))
|
||||
state = NUMBER;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/03 11:58:44 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/24 00:32:55 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 19:48:31 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -19,7 +19,9 @@ int lexer_delim(t_list **alst, char *str)
|
|||
token = (*alst)->content;
|
||||
while (ft_is_delim(*str))
|
||||
str++;
|
||||
if (token->type)
|
||||
if (*(str + 1) == '#')
|
||||
return (ft_tokenize(alst, str + 1, COMMENT));
|
||||
else if (token->type)
|
||||
return (ft_tokenize(&(*alst)->next, str, DEFAULT));
|
||||
else
|
||||
return (ft_tokenize(alst, str, DEFAULT));
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/03 12:06:35 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/23 22:51:25 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 19:06:00 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/03 11:56:58 by jhalford #+# #+# */
|
||||
/* Updated: 2016/12/03 11:57:09 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/01/24 19:02:45 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/23 23:19:46 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/24 17:54:12 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 20:13:45 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/03 12:07:11 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/24 17:33:09 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 18:50:42 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/21 22:49:31 by ariard #+# #+# */
|
||||
/* Updated: 2017/01/24 00:20:01 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 18:50:55 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/24 18:06:42 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 20:14:52 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ int shell_script()
|
|||
{
|
||||
if (ft_tokenize(&token, list_tmp->content , DEFAULT))
|
||||
return (1);
|
||||
if (!token)
|
||||
if (!token && !list_tmp->next)
|
||||
return (0);
|
||||
if (ft_post_tokenize(&token, list_tmp->content))
|
||||
return (1);
|
||||
|
|
@ -38,11 +38,12 @@ int shell_script()
|
|||
}
|
||||
DG("after post_tokenize");
|
||||
token_print(head);
|
||||
list_tmp = NULL;
|
||||
while (head)
|
||||
{
|
||||
if (ft_parse(&ast, &head))
|
||||
return (1);
|
||||
ft_lsteadd(&list_tmp, ft_lstnew(ast, sizeof (*ast)));
|
||||
ft_lsteadd(&list_tmp, ft_lstnew(ast, sizeof(*ast)));
|
||||
ast = NULL;
|
||||
ft_lst_delif(&head, head->content, &ft_addrcmp, &token_free);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/24 18:06:40 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 20:12:50 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 16:21:51 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/24 17:54:27 by ariard ### ########.fr */
|
||||
/* Updated: 2017/01/24 19:42:12 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue