still case
This commit is contained in:
parent
79bceb05a9
commit
ecc058dd11
4 changed files with 8 additions and 23 deletions
|
|
@ -9,33 +9,18 @@ int iscase(t_btree **ast, t_list **lst)
|
||||||
token = (*lst)->content;
|
token = (*lst)->content;
|
||||||
if (*ast)
|
if (*ast)
|
||||||
{
|
{
|
||||||
node = (*ast)->item;
|
node = (*ast)->item;
|
||||||
|
if (node->type == TK_PAREN_OPEN && node->full == 0 && node->nest > 0)
|
||||||
|
return (4);
|
||||||
if (node->type == TK_PAREN_OPEN && node->full == 0)
|
if (node->type == TK_PAREN_OPEN && node->full == 0)
|
||||||
{
|
|
||||||
// DG("go right");
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
|
||||||
if ((node->type == TK_CASE || node->type == TK_PAREN_OPEN
|
if ((node->type == TK_CASE || node->type == TK_PAREN_OPEN
|
||||||
|| iscase(&(*ast)->right, lst) == 1) && token->type == TK_WORD
|
|| iscase(&(*ast)->right, lst) == 1) && token->type == TK_WORD
|
||||||
&& node->pattern == 0)
|
&& node->pattern == 0)
|
||||||
{
|
|
||||||
// DG("add pattern");
|
|
||||||
return (2);
|
return (2);
|
||||||
}
|
if ((node->type == TK_CASE || iscase(&(*ast)->right, lst) == 1)
|
||||||
if ((node->type == TK_CASE || iscase(&(*ast)->right, lst) == 4)
|
|
||||||
&& token->type == TK_PAREN_OPEN)
|
&& token->type == TK_PAREN_OPEN)
|
||||||
{
|
|
||||||
// DG("new branch");
|
|
||||||
return (3);
|
return (3);
|
||||||
}
|
|
||||||
if ((node->type == TK_NEWLINE || node->type == TK_SEMI
|
|
||||||
|| node->type == TK_AMP) && iscase(&(*ast)->right, lst) == 1)
|
|
||||||
{
|
|
||||||
// DG(" go right");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (node->type == TK_PAREN_OPEN && node->nest == 0)
|
|
||||||
return (4);
|
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/15 20:49:15 by ariard #+# #+# */
|
/* Created: 2017/02/15 20:49:15 by ariard #+# #+# */
|
||||||
/* Updated: 2017/02/20 22:27:06 by jhalford ### ########.fr */
|
/* Updated: 2017/02/23 18:04:26 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/15 19:12:07 by ariard #+# #+# */
|
/* Created: 2017/02/15 19:12:07 by ariard #+# #+# */
|
||||||
/* Updated: 2017/02/20 17:46:54 by ariard ### ########.fr */
|
/* Updated: 2017/02/23 18:04:24 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ int add_sep(t_btree **ast, t_list **lst)
|
||||||
return (add_loop_sep(ast, lst));
|
return (add_loop_sep(ast, lst));
|
||||||
else if (iscondition(ast, lst) == 1)
|
else if (iscondition(ast, lst) == 1)
|
||||||
return (add_condition_sep(ast, lst));
|
return (add_condition_sep(ast, lst));
|
||||||
else if (iscase(ast, lst))
|
else if (iscase(ast, lst) == 1)
|
||||||
return (add_case_sep(ast, lst));
|
return (add_case_sep(ast, lst));
|
||||||
if (!*ast)
|
if (!*ast)
|
||||||
gen_node(ast);
|
gen_node(ast);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/15 18:32:59 by ariard #+# #+# */
|
/* Created: 2017/02/15 18:32:59 by ariard #+# #+# */
|
||||||
/* Updated: 2017/02/21 20:28:38 by ariard ### ########.fr */
|
/* Updated: 2017/02/23 18:03:35 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue