syntax fixes

This commit is contained in:
gazhonsepaskwa
2025-02-14 08:58:14 +01:00
parent 712cfe7f1d
commit e1bf337ded
3 changed files with 8 additions and 2 deletions

View File

@@ -23,7 +23,7 @@ t_node *remove_parentheses(t_node *lst)
it = lst; it = lst;
it = it->next; it = it->next;
deepness = 1; deepness = 1;
while (1) while (it)
{ {
str = ft_strdup(it->val); str = ft_strdup(it->val);
if (it->pressision == SUBSH_S) if (it->pressision == SUBSH_S)

View File

@@ -28,7 +28,7 @@ static int last_tok_redir(t_node *lst)
{ {
while (lst) while (lst)
{ {
if ((lst->next == NULL if ((lst->next == NULL
|| lst->next->pressision == D_RED_R || lst->next->pressision == D_RED_R
|| lst->next->pressision == RED_R || lst->next->pressision == RED_R
|| lst->next->pressision == RED_L || lst->next->pressision == RED_L

View File

@@ -107,6 +107,10 @@ int syntax_error(t_node *head)
return (syntax_err_mess(cpy->val, 0)); return (syntax_err_mess(cpy->val, 0));
while (cpy) while (cpy)
{ {
if (is_redir(cpy) && !cpy->next)
return (syntax_err_mess(cpy->val, 3));
if (is_redir(cpy) && cpy->next && cpy->next->next && !ft_strncmp(cpy->next->next->val, "(", 1))
return (syntax_err_mess(cpy->next->next->val, 0));
if (unexpected_token(cpy)) if (unexpected_token(cpy))
return (syntax_err_mess(cpy->val, 0)); return (syntax_err_mess(cpy->val, 0));
if (cpy->next == NULL && is_aop_operator(cpy)) if (cpy->next == NULL && is_aop_operator(cpy))
@@ -115,6 +119,8 @@ int syntax_error(t_node *head)
return (syntax_err_mess(cpy->next->val, 0)); return (syntax_err_mess(cpy->next->val, 0));
if (!ft_strncmp(cpy->val, ")", 1) && cpy->next && !ft_strncmp(cpy->next->val, "(", 1)) if (!ft_strncmp(cpy->val, ")", 1) && cpy->next && !ft_strncmp(cpy->next->val, "(", 1))
return (syntax_err_mess(cpy->next->val, 0)); return (syntax_err_mess(cpy->next->val, 0));
if (is_aop_operator(cpy) && !ft_strncmp(cpy->next->val, ")", 1))
return (syntax_err_mess(cpy->next->val, 0));
if (is_aop_operator(cpy) && is_aop_operator(cpy->next)) if (is_aop_operator(cpy) && is_aop_operator(cpy->next))
return (syntax_err_mess(cpy->next->val, 0)); return (syntax_err_mess(cpy->next->val, 0));
if (is_aop_operator(cpy) && ft_strlen(cpy->val) > 2) if (is_aop_operator(cpy) && ft_strlen(cpy->val) > 2)