42-archive/42sh/src/parser/add_sep.c
ariard@student.42.fr 5f596310e1 nesting case ok
2017-02-24 15:32:56 +01:00

40 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* add_sep.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 19:12:07 by ariard #+# #+# */
/* Updated: 2017/02/24 15:15:33 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "parser.h"
int add_sep(t_btree **ast, t_list **lst)
{
t_token *token;
t_astnode *node;
t_btree *new_node;
DG("add sep");
if (isloop(ast) == 1)
return (add_loop_sep(ast, lst));
else if (iscondition(ast, lst) == 1)
return (add_condition_sep(ast, lst));
else if (iscase(ast, lst) == 2)
return (add_case_sep(ast, lst));
if (!*ast)
gen_node(ast);
token = (*lst)->content;
// if (node->type != TK_DO)
// {
new_node = NULL;
gen_node(&new_node);
join_ast(ast, &new_node);
node = (new_node)->item;
// }
node->type = token->type;
return (0);
}