a bit of code cleaning on the parser
This commit is contained in:
parent
a51c8ad81d
commit
ee59b79e75
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/18 09:25:05 by tmaze #+# #+# */
|
||||
/* Updated: 2019/04/21 14:42:08 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:08:31 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/18 09:59:11 by tmaze #+# #+# */
|
||||
/* Updated: 2019/04/26 12:49:36 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:14:04 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -109,14 +109,11 @@ t_ind **edmonds_karp(t_lmdata *data, int s_ind, int e_ind)
|
||||
scores[0] = 0;
|
||||
nb_paths = 0;
|
||||
i = 0;
|
||||
ft_printf("data: %p\ndata->nb_nodes: %d\ndata->adj: %p\n\n", data, data->nb_nodes, data->adj);
|
||||
while (i < data->nb_nodes)
|
||||
tab[i++].old_visited = 0;
|
||||
bfs(data, tab, s_ind, e_ind);
|
||||
ft_printf("tab[e_ind].parent: %d\n", tab[e_ind].parent);
|
||||
while (tab[e_ind].parent != -1)
|
||||
{
|
||||
ft_printf("new path\n");
|
||||
nb_paths++;
|
||||
update_weights(data, tab, s_ind, e_ind);
|
||||
ret[1] = resolve_paths(data, nb_paths, s_ind, e_ind);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/25 06:31:05 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/29 12:40:52 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:21:10 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/05 06:35:40 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/29 12:06:18 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:14:50 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/29 07:17:06 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/29 12:05:52 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:15:04 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/23 17:43:34 by tmaze #+# #+# */
|
||||
/* Updated: 2019/04/29 12:08:36 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:06:35 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/25 06:31:37 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/29 12:07:09 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:56:14 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/20 15:24:51 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/29 12:45:25 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/30 12:06:22 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -59,14 +59,14 @@ static int lm_get_ant_(int counter, t_lmdata *ldata
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int lm_get_vertices(int count, t_syntax *synt
|
||||
, t_lmdata *data, t_holder *holder, char *line)
|
||||
static int lm_get_vertices(int count, t_lmdata *data
|
||||
, t_syntax *syntax, t_holder *holder, char *line)
|
||||
{
|
||||
lm_get_cmd_vert(count, synt, data, line);
|
||||
if (!synt->s_error && !synt->e_error)
|
||||
lm_get_cmd_vert(count, syntax, data, line);
|
||||
if (!syntax->s_error && !syntax->e_error)
|
||||
{
|
||||
lm_get_vert_link(count, synt, data, holder, line);
|
||||
if (!synt->v_error && !synt->l_error)
|
||||
lm_get_vert_link(count, data, syntax, holder, line);
|
||||
if (!syntax->v_error && !syntax->l_error)
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
@ -84,17 +84,10 @@ int lm_parser(t_syntax *synt
|
||||
if ((add_line_map(ldata, raw)))
|
||||
return (0);
|
||||
if (!(lm_get_ant_(index, ldata, synt, raw)) && index == 0)
|
||||
{
|
||||
//ft_strdel(&raw);
|
||||
return (0);
|
||||
}
|
||||
lm_locate_cd(index, synt, raw);
|
||||
if (!(lm_get_vertices(index, synt, ldata, holder, raw)))
|
||||
{
|
||||
ft_strdel(&raw);
|
||||
if (!(lm_get_vertices(index, ldata, synt, holder, raw)))
|
||||
return (0);
|
||||
}
|
||||
ft_strdel(&raw);
|
||||
index++;
|
||||
}
|
||||
ft_strdel(&raw);
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/29 11:50:04 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/29 12:10:09 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:19:29 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/04 09:24:45 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/29 12:05:40 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/30 08:16:49 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -61,22 +61,23 @@ void lm_get_cmd_vert(int count, t_syntax *synt
|
||||
}
|
||||
}
|
||||
|
||||
void lm_get_vert_link(int count, t_syntax *synt
|
||||
, t_lmdata *ldata, t_holder *holder, char *line)
|
||||
void lm_get_vert_link(int count, t_lmdata *ldata
|
||||
, t_syntax *syntax, t_holder *holder, char *line)
|
||||
{
|
||||
if (count > 0 && (count != synt->s_vert && count != synt->e_vert)
|
||||
&& (count != synt->s_pos
|
||||
&& count != synt->e_pos && line != NULL))
|
||||
if (count > 0 && (count != syntax->s_vert
|
||||
&& count != syntax->e_vert)
|
||||
&& (count != syntax->s_pos
|
||||
&& count != syntax->e_pos && line != NULL))
|
||||
{
|
||||
if (lm_check_forbiden_chars(line, 0))
|
||||
{
|
||||
if (!(lm_add_vertex(ldata, line, 'v', synt)))
|
||||
synt->v_error = 1;
|
||||
if (!(lm_add_vertex(ldata, line, 'v', syntax)))
|
||||
syntax->v_error = 1;
|
||||
}
|
||||
if (lm_check_forbiden_chars(line, 3))
|
||||
{
|
||||
if (!(lm_ext_conn(holder, ldata, line)))
|
||||
synt->l_error = 1;
|
||||
syntax->l_error = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/27 14:56:55 by tmaze #+# #+# */
|
||||
/* Updated: 2019/04/24 09:51:38 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:19:43 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/06 11:37:56 by tmaze #+# #+# */
|
||||
/* Updated: 2019/04/21 16:14:45 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:05:43 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/10 11:23:36 by tmaze #+# #+# */
|
||||
/* Updated: 2019/04/18 19:04:49 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:06:08 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/18 18:05:06 by tmaze #+# #+# */
|
||||
/* Updated: 2019/04/21 16:53:11 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/30 07:05:10 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user