/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* lem_in.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mndhlovu +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/25 06:31:05 by mndhlovu #+# #+# */ /* Updated: 2019/04/08 15:15:17 by mndhlovu ### ########.fr */ /* */ /* ************************************************************************** */ #include "lem_in.h" int lm_error_exit(void) { ft_putendl_fd("ERROR", 2); return (1); } void ft_print_graph(t_graph *graph) { int v; t_ind *crawl; v = -1; while (++v < graph->v) { crawl = graph->array[v].head; printf("\n Adjacency list of vertex %d\n head", v); while (crawl) { printf("->%d",crawl->index); crawl = crawl->next; } printf("\n"); } } void lm_print_report(t_lmdata *ldata, t_syntax *synt, t_holder *holder) { t_node *nodes; t_temp *data; if (ldata != NULL) { nodes = ldata->nodes_data; while (nodes) { ft_printf("name: %s x: %d y: %d index: %d role: %c\n", nodes->name, nodes->x, nodes->y, nodes->ind, nodes->role); nodes = nodes->next; } } if (holder != NULL) { data = holder->data; while (data) { ft_printf("src: %d - dest: %d\n", data->src_ind, data->dest_ind); data = data->next; } } ft_printf("nb_state: %d\n s_cmd: %d\n e_cmd: %d\n s_error: %d\n e_rror: %d\n v_error: %d\n l_error: %d\n", synt->nb_state, synt->s_cmd, synt->e_cmd, synt->s_error, synt->e_error, synt->v_error, synt->l_error); } static int lem_in(t_syntax *synt, t_holder *holder, t_lmdata *lmdata, t_graph *graph) { if (!(lm_parser(synt, lmdata, holder))) return (0); graph = lm_creategraph(lmdata->nb_nodes); if (!(lm_adj_parser(graph, holder))) return (0); ft_print_graph(graph); return (1); } int main(int ac, char **av) { t_syntax synt; t_graph graph; t_lmdata ldata; t_holder holder; (void)av; if (ac == 1) { if (!(lm_init_memory(&synt, &holder, &ldata))) return (lm_error_exit()); if (!(lem_in(&synt, &holder, &ldata, &graph))) return (lm_error_exit()); return (0); } return (1); }