clean up still in progress

eliminated most of the leaks of the parser
norming still need to be done
This commit is contained in:
Tanguy MAZE
2019-04-11 11:40:26 +02:00
parent 8c4a6aac25
commit 86b0530bf7
6 changed files with 82 additions and 130 deletions

View File

@@ -6,44 +6,12 @@
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/25 06:30:51 by mndhlovu #+# #+# */
/* Updated: 2019/04/08 15:44:55 by tmaze ### ########.fr */
/* Updated: 2019/04/11 09:51:29 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "lem_in.h"
// void lm_locate_cmd(t_syntax *synt)
// {
// char *line;
// char *tmp;
// int index;
// index = 0;
// while (ft_getline(&line) > 0)
// {
// tmp = ft_strchr(line, '#');
// if ((!synt->s_cmd || !synt->e_cmd) && (tmp != NULL && line[1] == '#'))
// {
// if (!synt->s_cmd)
// {
// if (ft_strcmp(tmp, "##start") == 0)
// {
// synt->s_cmd = 1;
// }
// }
// if (!synt->e_cmd)
// {
// if (ft_strcmp(tmp, "##end") == 0)
// {
// synt->e_cmd = 1;
// synt->e_pos = index;
// }
// }
// }
// index++;
// }
// }
void lm_locate_cd(int index, t_syntax *synt, char *line)
{
char *tmp;
@@ -70,57 +38,6 @@ void lm_locate_cd(int index, t_syntax *synt, char *line)
}
}
// void lm_locate_cmd(t_syntax *synt)
// {
// char *line;
// char *tmp;
// int index;
// index = 0;
// while (ft_getline(&line) > 0)
// {
// tmp = ft_strchr(line, '#');
// if ((!synt->s_cmd || !synt->e_cmd) && (tmp != NULL && line[1] == '#'))
// {
// if (!synt->s_cmd)
// {
// if (ft_strcmp(tmp, "##start") == 0)
// {
// synt->s_cmd = 1;
// }
// }
// if (!synt->e_cmd)
// {
// if (ft_strcmp(tmp, "##end") == 0)
// {
// synt->e_cmd = 1;
// synt->e_pos = index;
// }
// }
// }
// index++;
// }
// }
// int lm_get_ant_num(t_lmdata *ldata, t_syntax *synt)
// {
// char *line;
// int value;
// if (ft_getline(&line) > 0)
// {
// value = lm_get_value(line);
// if (value != -1)
// {
// ldata->nbants = value;
// synt->nb_state = 1;
// return (1);
// }
// free(line);
// }
// return (0);
// }
int lm_get_ant_(int counter, t_lmdata *ldata, t_syntax *synt, char *line)
{
int value;
@@ -161,13 +78,22 @@ int lm_parser(t_syntax *synt, t_lmdata *ldata,
index = 0;
while (ft_getline(&raw) > 0)
{
ft_printf("%s\n", raw);
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);
return (0);
}
ft_strdel(&raw);
index++;
}
free(raw);
ft_strdel(&raw);
ft_putchar('\n');
return (1);
}