drawio generator
This commit is contained in:
20
tests/ast/ast.c
Normal file
20
tests/ast/ast.c
Normal file
@@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ast.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/24 08:22:16 by nalebrun #+# #+# */
|
||||
/* Updated: 2025/01/24 08:22:16 by nalebrun ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ast.h"
|
||||
|
||||
/*void ast(t_node *token_lst)*/
|
||||
/*{*/
|
||||
/* t_node *head = token_lst;*/
|
||||
/**/
|
||||
/**/
|
||||
/*}*/
|
||||
19
tests/ast/ast.h
Normal file
19
tests/ast/ast.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ast.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/24 08:23:27 by nalebrun #+# #+# */
|
||||
/* Updated: 2025/01/24 08:23:27 by nalebrun ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef AST_H
|
||||
# define AST_H
|
||||
|
||||
#include "../../includes/minishell.h"
|
||||
#include "../tokenizer/tokenizer.h"
|
||||
|
||||
#endif
|
||||
@@ -37,6 +37,36 @@ void truncate_comment(char *str)
|
||||
}
|
||||
}
|
||||
|
||||
void gen_dio_linked_list(t_node *head, char *fp)
|
||||
{
|
||||
int fd;
|
||||
t_dio_elem rect;
|
||||
t_dio_elem arrow;
|
||||
t_node *current;
|
||||
|
||||
current = head;
|
||||
fd = drawio_init(fp);
|
||||
rect.type = RECT;
|
||||
rect.rounded = 0;
|
||||
rect.x = 50;
|
||||
rect.y = 50;
|
||||
rect.w = 100;
|
||||
rect.h = 50;
|
||||
arrow.id_src = 0;
|
||||
arrow.type = ARROW;
|
||||
while (current != NULL)
|
||||
{
|
||||
rect.text = ft_sprintf("%s", current->val);
|
||||
arrow.id_dst = drawio_create_elem(fd, &rect);
|
||||
drawio_create_elem(fd, &arrow);
|
||||
arrow.id_src = arrow.id_dst;
|
||||
rect.x += 150;
|
||||
free(rect.text);
|
||||
current = current->next;
|
||||
}
|
||||
drawio_end_file(fd);
|
||||
}
|
||||
|
||||
/*static t_data *init_data(char **envp)*/
|
||||
/*{*/
|
||||
/* t_data *data;*/
|
||||
@@ -52,13 +82,21 @@ int main(int ac, char **av, char **envp)
|
||||
|
||||
(void)ac;
|
||||
(void)envp;
|
||||
|
||||
if (ac != 3)
|
||||
{
|
||||
ft_error("./test drawio_file command_str\n");
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*t_data data;*/
|
||||
|
||||
/*data = init_data(envp);*/
|
||||
truncate_comment(av[1]);
|
||||
lst = tokenize(av[1]);
|
||||
lst = tokenize(av[2]);
|
||||
if (!lst)
|
||||
return (1);
|
||||
debug_linked_list(lst, "Tokenized");
|
||||
gen_dio_linked_list(lst, av[1]);
|
||||
free_linked_list(lst);
|
||||
}
|
||||
@@ -111,16 +111,12 @@ t_node *tokenize(char *str)
|
||||
head = tokenize_base(str);
|
||||
if (!head)
|
||||
return (NULL);
|
||||
debug_linked_list(head, "Base_cut");
|
||||
if (!trim_nodes(head))
|
||||
return (NULL);
|
||||
debug_linked_list(head, "Trimed");
|
||||
if (!unstick_nodes(head))
|
||||
return (NULL);
|
||||
debug_linked_list(head, "Nodes Unsticked");
|
||||
stick_quote_node(head, 39);
|
||||
stick_quote_node(head, '"');
|
||||
debug_linked_list(head, "Quote Sticked");
|
||||
set_token(head);
|
||||
return (head);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user