parsing heredoc doing

This commit is contained in:
ariard@student.42.fr 2017-02-25 20:36:27 +01:00
parent eeb0887081
commit 8c8ee2152e
16 changed files with 26 additions and 14 deletions

2
42sh/file Normal file
View file

@ -0,0 +1,2 @@
ls: feew: No such file or directory
ls: feew: No such file or directory

0
42sh/file1 Normal file
View file

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */ /* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */
/* Updated: 2017/02/25 18:47:20 by ariard ### ########.fr */ /* Updated: 2017/02/25 19:37:31 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -1 +1 @@
ls >> 1 >> 2 >> 3 < 4 < 5 ; pwd > 1 > 2

View file

@ -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/02/24 20:43:56 by ariard ### ########.fr */ /* Updated: 2017/02/25 20:04:41 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -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/02/21 22:42:41 by ariard ### ########.fr */ /* Updated: 2017/02/25 19:56:31 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -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/02/21 21:09:31 by ariard ### ########.fr */ /* Updated: 2017/02/25 20:12:58 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,6 +21,7 @@ int lexer_great(t_list **alst, t_lexer *lexer)
lexer->pos++; lexer->pos++;
if (lexer->str[lexer->pos] == '&') if (lexer->str[lexer->pos] == '&')
{ {
DG("lex greatand");
token->type = TK_GREATAND; token->type = TK_GREATAND;
token_append(token, lexer, 0, 0); token_append(token, lexer, 0, 0);
lexer->pos++; lexer->pos++;
@ -28,6 +29,7 @@ int lexer_great(t_list **alst, t_lexer *lexer)
} }
if (lexer->str[lexer->pos] == '>') if (lexer->str[lexer->pos] == '>')
{ {
DG("lex great");
token->type = TK_DGREAT; token->type = TK_DGREAT;
token_append(token, lexer, 0, 0); token_append(token, lexer, 0, 0);
lexer->pos++; lexer->pos++;

View file

@ -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: 2017/02/20 20:52:49 by ariard ### ########.fr */ /* Updated: 2017/02/25 20:11:03 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 12:06:53 by jhalford #+# #+# */ /* Created: 2016/12/03 12:06:53 by jhalford #+# #+# */
/* Updated: 2017/02/20 20:53:06 by ariard ### ########.fr */ /* Updated: 2017/02/25 20:11:17 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 11:58:51 by jhalford #+# #+# */ /* Created: 2016/12/03 11:58:51 by jhalford #+# #+# */
/* Updated: 2017/02/09 19:56:29 by jhalford ### ########.fr */ /* Updated: 2017/02/25 20:11:10 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 12:06:45 by jhalford #+# #+# */ /* Created: 2016/12/03 12:06:45 by jhalford #+# #+# */
/* Updated: 2017/02/20 20:53:20 by ariard ### ########.fr */ /* Updated: 2017/02/25 19:55:30 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,6 +18,7 @@ int lexer_number(t_list **alst, t_lexer *lexer)
t_lexstate state; t_lexstate state;
token = (*alst)->content; token = (*alst)->content;
token->type = TK_IO_NUMBER;
if ((state = get_state_global(lexer))) if ((state = get_state_global(lexer)))
{ {
lexer->state = state; lexer->state = state;

View file

@ -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/02/24 21:00:15 by ariard ### ########.fr */ /* Updated: 2017/02/25 20:10:39 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,6 +19,7 @@ int lexer_word(t_list **alst, t_lexer *lexer)
token = (*alst)->content; token = (*alst)->content;
token->type = TK_WORD; token->type = TK_WORD;
DG("lexer word");
if ((state = get_state_global(lexer))) if ((state = get_state_global(lexer)))
{ {
lexer->state = state; lexer->state = state;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/02/25 18:25:11 by ariard ### ########.fr */ /* Updated: 2017/02/25 20:34:27 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -61,6 +61,7 @@ int handle_instruction(int fd)
else if (parser.state == ERROR) else if (parser.state == ERROR)
error_syntax(&token); error_syntax(&token);
token = NULL; token = NULL;
ast = NULL;
} }
DG("succesful parsing:"); DG("succesful parsing:");
btree_print(STDBUG, ast, &ft_putast); btree_print(STDBUG, ast, &ft_putast);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/17 16:39:05 by ariard #+# #+# */ /* Created: 2017/02/17 16:39:05 by ariard #+# #+# */
/* Updated: 2017/02/25 19:29:53 by ariard ### ########.fr */ /* Updated: 2017/02/25 20:33:12 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,7 +18,7 @@ int isdir(t_btree **ast, t_list **list)
t_token *token; t_token *token;
token = (*list)->content; token = (*list)->content;
if (ast) if (*ast)
{ {
DG("isdir"); DG("isdir");
node = (*ast)->item; node = (*ast)->item;
@ -61,7 +61,9 @@ int add_redir(t_btree **ast, t_list **lst)
t_token *token; t_token *token;
t_redir *redir; t_redir *redir;
DG("add_redir"); DG("add redir");
if (!ast)
gen_node(ast);
token = (*lst)->content; token = (*lst)->content;
node = (*ast)->item; node = (*ast)->item;
redir = ft_memalloc(sizeof(redir)); redir = ft_memalloc(sizeof(redir));

1
42sh/wide Normal file
View file

@ -0,0 +1 @@
ls: ewfef: No such file or directory

2
42sh/yolo Normal file
View file

@ -0,0 +1,2 @@
ls: wefewf: No such file or directory
ls: wefewf: No such file or directory