This commit is contained in:
gazhonsepaskwa
2025-02-07 12:35:13 +01:00
parent 4d63a10900
commit 4c678f767d
6 changed files with 76 additions and 13 deletions

View File

@@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test.c :+: :+: :+: */
/* parser.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/15 08:23:41 by nalebrun #+# #+# */
/* Updated: 2025/02/03 11:49:21 by nalebrun ### ########.fr */
/* Updated: 2025/02/07 12:08:40 by nalebrun ### ########.fr */
/* */
/* ************************************************************************** */
@@ -46,6 +46,8 @@ t_ast_n *parser(char *input, t_msh *msh)
lst = tokenize(input);
if (!lst)
return (NULL);
if (syntax_error(lst))
return (NULL);
if (DEBUG)
{
dio = drawio_init("ast.xml");

41
srcs/parsing/syntax.c Normal file
View File

@@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* syntax.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/07 12:08:53 by nalebrun #+# #+# */
/* Updated: 2025/02/07 12:08:53 by nalebrun ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../includes/parser/parsing.h"
int only_operator(t_node *head)
{
if (!head->next && head->token == OPERATOR)
return (1);
return (0);
}
int syntax_err_mess(char *token)
{
ft_fprintf(2, "minishell : syntax error near unexpected token `%s'\n", token);
return (1);
}
int syntax_error(t_node *head)
{
// t_node *cpy;
if (only_operator(head))
return(syntax_err_mess(head->val));
// cpy = node;
// while (cpy)
// {
// cpy = cpy->next;
// }
return (0);
}