a bit more of normalising
normalising lem_in WIP
This commit is contained in:
@@ -6,19 +6,27 @@
|
||||
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/25 06:31:05 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/10 14:26:07 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/10 15:35:18 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "lem_in.h"
|
||||
|
||||
int lm_error_exit(void)
|
||||
static t_node *get_node_role(t_lmdata *data, char role)
|
||||
{
|
||||
ft_putendl_fd("ERROR", 2);
|
||||
return (1);
|
||||
t_node *it;
|
||||
|
||||
it = data->nodes_data;
|
||||
while (it)
|
||||
{
|
||||
if (it->role == role)
|
||||
return (it);
|
||||
it = it->next;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static int lem_in(t_syntax *synt, t_holder *holder,
|
||||
static int lem_in(t_syntax *synt, t_holder *holder,
|
||||
t_lmdata *lmdata)
|
||||
{
|
||||
if (!(lm_parser(synt, lmdata, holder)))
|
||||
@@ -30,16 +38,19 @@ static int lem_in(t_syntax *synt, t_holder *holder,
|
||||
return (1);
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
int lm_error_exit(void)
|
||||
{
|
||||
t_syntax synt;
|
||||
t_lmdata ldata;
|
||||
t_holder holder;
|
||||
t_ind **ret;
|
||||
t_node *it;
|
||||
t_node *start;
|
||||
t_node *end;
|
||||
int i;
|
||||
ft_putendl_fd("ERROR", 2);
|
||||
return (1);
|
||||
}
|
||||
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
t_syntax synt;
|
||||
t_lmdata ldata;
|
||||
t_holder holder;
|
||||
t_ind **ret;
|
||||
int i;
|
||||
|
||||
(void)av;
|
||||
i = 0;
|
||||
@@ -48,19 +59,12 @@ int main(int ac, char **av)
|
||||
lm_init_data(&synt, &holder, &ldata);
|
||||
if (!(lem_in(&synt, &holder, &ldata)))
|
||||
return (lm_error_exit());
|
||||
it = ldata.nodes_data;
|
||||
start = NULL;
|
||||
end = NULL;
|
||||
while (it && (!start || !end))
|
||||
{
|
||||
if (it->role == 's')
|
||||
start = it;
|
||||
else if (it->role == 'e')
|
||||
end = it;
|
||||
it = it->next;
|
||||
}
|
||||
if ((!start) || (ret = edmunds_karp(&ldata, start->ind, end->ind)) == NULL)
|
||||
if ((ret = edmunds_karp(&ldata, get_node_role(&ldata, 's')->ind
|
||||
, get_node_role(&ldata, 'e')->ind)) == NULL)
|
||||
return (lm_error_exit());
|
||||
i = 0;
|
||||
while (ret[i])
|
||||
i++;
|
||||
push_ants(&ldata, ret, i);
|
||||
tablst_inddel(ret);
|
||||
i = 0;
|
||||
|
||||
Reference in New Issue
Block a user