starting to fixi redirections

This commit is contained in:
Jack Halford 2017-02-03 13:21:06 +01:00
parent 7265a6c340
commit 985745f881
9 changed files with 45 additions and 15 deletions

View file

@ -187,6 +187,7 @@ parser/parse_great.c\
parser/parse_greatand.c\
parser/parse_less.c\
parser/parse_lessand.c\
parser/parse_redir.c\
parser/parse_separator.c\
parser/parse_subshell.c\
parser/parse_word.c

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 12:15:54 by jhalford #+# #+# */
/* Updated: 2017/02/02 14:03:15 by jhalford ### ########.fr */
/* Updated: 2017/02/02 19:03:31 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -60,6 +60,7 @@ extern t_parser g_parser[];
int ft_parse(t_btree **ast, t_list **token);
int parse_separator(t_btree **ast, t_list **start, t_list **lst);
int parse_redir(t_btree **ast, t_list **start, t_list **lst);
int parse_less(t_btree **ast, t_list **start, t_list **lst);
int parse_great(t_btree **ast, t_list **start, t_list **lst);
int parse_dless(t_btree **ast, t_list **start, t_list **lst);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 17:27:51 by jhalford #+# #+# */
/* Updated: 2016/12/13 17:14:19 by jhalford ### ########.fr */
/* Updated: 2017/02/02 19:06:38 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */
/* Updated: 2017/02/02 15:04:50 by jhalford ### ########.fr */
/* Updated: 2017/02/02 19:06:47 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/02/02 15:45:17 by jhalford ### ########.fr */
/* Updated: 2017/02/02 18:57:56 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */
/* Updated: 2017/02/02 15:45:33 by jhalford ### ########.fr */
/* Updated: 2017/02/02 19:02:32 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,12 +18,7 @@ t_parser g_parser[] =
{TK_AND_IF | TK_OR_IF, &parse_separator},
{TK_AMP, &parse_separator},
{TK_PIPE, &parse_separator},
{TK_LESS, &parse_less},
{TK_GREAT, &parse_great},
{TK_DLESS, &parse_dless},
{TK_DGREAT, &parse_dgreat},
{TK_LESSAND, &parse_lessand},
{TK_GREATAND, &parse_greatand},
{TK_REDIR, &parse_redir},
{TK_SUBSHELL, &parse_subshell},
{TK_WORD, &parse_word},
{0, 0},
@ -48,8 +43,7 @@ int ft_parse(t_btree **ast, t_list **start)
if ((lst = ft_lst_find(*start, &g_parser[i].type, &token_cmp_type)))
{
if (g_parser[i].f)
(*g_parser[i].f)(ast, start, &lst);
return (0);
return ((*g_parser[i].f)(ast, start, &lst));
}
i++;
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 12:49:45 by jhalford #+# #+# */
/* Updated: 2017/01/10 14:44:12 by jhalford ### ########.fr */
/* Updated: 2017/02/02 19:02:52 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 12:49:45 by jhalford #+# #+# */
/* Updated: 2017/01/10 14:45:50 by jhalford ### ########.fr */
/* Updated: 2017/02/02 19:05:52 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse_redir.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/02 18:58:27 by jhalford #+# #+# */
/* Updated: 2017/02/02 19:04:32 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "parser.h"
int parse_redir(t_btree **ast, t_list **start, t_list **lst)
{
t_token *tok;
tok = (*lst)->content;
if (tok->type == TK_LESS)
return (parse_less(ast, start, lst));
else if (tok->type == TK_GREAT)
return (parse_great(ast, start, lst));
else if (tok->type == TK_DLESS)
return (parse_dless(ast, start, lst));
else if (tok->type == TK_DGREAT)
return (parse_dgreat(ast, start, lst));
else if (tok->type == TK_LESSAND)
return (parse_lessand(ast, start, lst));
else if (tok->type == TK_GREATAND)
return (parse_greatand(ast, start, lst));
else
return (-42);
}