This commit is contained in:
Nathan Lebrun
2025-01-29 11:40:30 +01:00
parent 9bce0bf9cb
commit 64100fe0f4
19 changed files with 29 additions and 91 deletions

69
test/test.c Normal file
View File

@@ -0,0 +1,69 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/15 08:23:41 by nalebrun #+# #+# */
/* Updated: 2025/01/20 13:15:47 by nalebrun ### ########.fr */
/* */
/* ************************************************************************** */
#include "parsing.h"
void truncate_comment(char *str)
{
int i;
char inquote;
if (!str)
return ;
i = 0;
inquote = 0;
while (str[i])
{
if (!inquote && (str[i] == 39 || str[i] == '"'))
inquote = str[i];
else if (inquote && (str[i] == inquote))
inquote = 0;
if (str[i] == '#' && !inquote && str[i - 1] && str[i - 1] != '\\')
{
str[i] = 0;
return ;
}
i++;
}
}
int main(int ac, char **av, char **envp)
{
t_node *lst;
t_ast_n *ast;
int dio;
if (ac != 3)
{
ft_error("./test drawio_file command_str\n");
return (1);
}
truncate_comment(av[1]);
lst = tokenize(av[2]);
if (!lst)
return (1);
if (DEBUG)
{
dio = drawio_init(av[1]);
gen_dio_linked_list(lst, dio);
}
ast = get_ast(envp, lst);
if (!ast)
return (1);
if (DEBUG)
{
gen_dio_ast(ast, dio);
drawio_end_file(dio);
ft_debug(" draw.io file generated !\n");
}
free_linked_list(lst);
}