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> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* 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/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,
|
BACKSLASH,
|
||||||
VAR,
|
VAR,
|
||||||
SPECIAL,
|
SPECIAL,
|
||||||
|
COMMENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct s_token
|
struct s_token
|
||||||
|
|
@ -94,6 +95,7 @@ int ft_is_delim(char c);
|
||||||
|
|
||||||
t_lexstate get_lexer_state(char *str);
|
t_lexstate get_lexer_state(char *str);
|
||||||
int lexer_default(t_list **alst, 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_newline(t_list **alst, char *str);
|
||||||
int lexer_delim(t_list **alst, char *str);
|
int lexer_delim(t_list **alst, char *str);
|
||||||
int lexer_sep(t_list **alst, char *str);
|
int lexer_sep(t_list **alst, char *str);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/01 12:15:54 by jhalford #+# #+# */
|
/* 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
|
ls | wc -l > file1 ; cd
|
||||||
cd ; ls
|
|
||||||
pwd ; echo "hello world"
|
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> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* 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/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_backslash,
|
||||||
&lexer_var,
|
&lexer_var,
|
||||||
&lexer_special,
|
&lexer_special,
|
||||||
|
&lexer_comment,
|
||||||
};
|
};
|
||||||
|
|
||||||
int ft_is_delim(char c)
|
int ft_is_delim(char c)
|
||||||
|
|
|
||||||
|
|
@ -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/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> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 18:36:21 by jhalford #+# #+# */
|
/* 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));
|
return (ft_tokenize(alst, str, GREAT));
|
||||||
else if (*str == '<')
|
else if (*str == '<')
|
||||||
return (ft_tokenize(alst, str, LESS));
|
return (ft_tokenize(alst, str, LESS));
|
||||||
|
else if (*str == '#')
|
||||||
|
return (ft_tokenize(alst, str, COMMENT));
|
||||||
else if (ft_isdigit(*str))
|
else if (ft_isdigit(*str))
|
||||||
state = NUMBER;
|
state = NUMBER;
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -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/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;
|
token = (*alst)->content;
|
||||||
while (ft_is_delim(*str))
|
while (ft_is_delim(*str))
|
||||||
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));
|
return (ft_tokenize(&(*alst)->next, str, DEFAULT));
|
||||||
else
|
else
|
||||||
return (ft_tokenize(alst, str, DEFAULT));
|
return (ft_tokenize(alst, str, DEFAULT));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:06:35 by jhalford #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 11:56:58 by jhalford #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* 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/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> +#+ +:+ +#+ */
|
/* 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/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> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/21 22:49:31 by ariard #+# #+# */
|
/* 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> +#+ +:+ +#+ */
|
/* 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/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))
|
if (ft_tokenize(&token, list_tmp->content , DEFAULT))
|
||||||
return (1);
|
return (1);
|
||||||
if (!token)
|
if (!token && !list_tmp->next)
|
||||||
return (0);
|
return (0);
|
||||||
if (ft_post_tokenize(&token, list_tmp->content))
|
if (ft_post_tokenize(&token, list_tmp->content))
|
||||||
return (1);
|
return (1);
|
||||||
|
|
@ -38,6 +38,7 @@ int shell_script()
|
||||||
}
|
}
|
||||||
DG("after post_tokenize");
|
DG("after post_tokenize");
|
||||||
token_print(head);
|
token_print(head);
|
||||||
|
list_tmp = NULL;
|
||||||
while (head)
|
while (head)
|
||||||
{
|
{
|
||||||
if (ft_parse(&ast, &head))
|
if (ft_parse(&ast, &head))
|
||||||
|
|
|
||||||
|
|
@ -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/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> +#+ +:+ +#+ */
|
/* 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/24 17:54:27 by ariard ### ########.fr */
|
/* Updated: 2017/01/24 19:42:12 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue