fixes
This commit is contained in:
@@ -33,6 +33,7 @@ static void free_pline(t_ast_n *node)
|
|||||||
i = -1;
|
i = -1;
|
||||||
while (node->pline[++i])
|
while (node->pline[++i])
|
||||||
free_ast(node->pline[i]);
|
free_ast(node->pline[i]);
|
||||||
|
free(node->pline);
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_ast(t_ast_n *node)
|
void free_ast(t_ast_n *node)
|
||||||
|
|||||||
@@ -97,24 +97,33 @@ int unclosed(t_node *head)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int is_aop_operator(t_node *node)
|
||||||
|
{
|
||||||
|
if (!node || node->token != OPERATOR)
|
||||||
|
return (0);
|
||||||
|
if (node->pressision == AND
|
||||||
|
|| node->pressision == OR
|
||||||
|
|| node->pressision == PIPE)
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int syntax_error(t_node *head)
|
int syntax_error(t_node *head)
|
||||||
{
|
{
|
||||||
t_node *cpy;
|
t_node *cpy;
|
||||||
|
|
||||||
cpy = head;
|
cpy = head;
|
||||||
if (cpy->token == OPERATOR && cpy->next && cpy->next->token == OPERATOR)
|
if (is_aop_operator(cpy) && cpy->next == NULL)
|
||||||
return (syntax_err_mess(cpy->next->val, 0));
|
|
||||||
if (cpy->token == OPERATOR && cpy->pressision != SUBSH_S)
|
|
||||||
return (syntax_err_mess(cpy->val, 0));
|
return (syntax_err_mess(cpy->val, 0));
|
||||||
while (cpy)
|
while (cpy)
|
||||||
{
|
{
|
||||||
if (unexpected_token(cpy))
|
if (unexpected_token(cpy))
|
||||||
return (syntax_err_mess(cpy->val, 0));
|
return (syntax_err_mess(cpy->val, 0));
|
||||||
if (cpy->token == OPERATOR && cpy->next == NULL && cpy->pressision != SUBSH_E)
|
if (cpy->next == NULL && is_aop_operator(cpy))
|
||||||
return (syntax_err_mess(cpy->val, 3));
|
return (syntax_err_mess(cpy->val, 3));
|
||||||
if (cpy->token == OPERATOR && cpy->pressision != SUBSH_E && cpy->next && cpy->next->token == OPERATOR)
|
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 (cpy->token == OPERATOR && ft_strlen(cpy->val) > 2)
|
if (is_aop_operator(cpy) && ft_strlen(cpy->val) > 2)
|
||||||
return (syntax_err_mess(cpy->val, 0));
|
return (syntax_err_mess(cpy->val, 0));
|
||||||
cpy = cpy->next;
|
cpy = cpy->next;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user