code cleaning done on 80 percent of the parser functions, whats left is to re structure the syntax struct and do furthure tests to eliminate level 0 errors
This commit is contained in:
@@ -6,52 +6,49 @@
|
||||
/* By: mndhlovu <mndhlovu@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/22 08:55:30 by mndhlovu #+# #+# */
|
||||
/* Updated: 2019/04/26 13:35:05 by mndhlovu ### ########.fr */
|
||||
/* Updated: 2019/04/29 12:06:41 by mndhlovu ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "lem_in.h"
|
||||
|
||||
int lm_check_room_before(char **tab, t_syntax *synt)
|
||||
int lm_check_room_before(char **tab, t_syntax *synt)
|
||||
{
|
||||
if (tab[0] != NULL && tab[1] != NULL && tab[2] != NULL)
|
||||
{
|
||||
if (lm_validate_rooms(tab[0], tab[1], tab[2]))
|
||||
if (tab[0] != NULL && tab[1] != NULL && tab[2] != NULL)
|
||||
{
|
||||
if (lm_validate_rooms(tab[0], tab[1], tab[2]))
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
synt->v_error = 1;
|
||||
return (0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int lm_check_forbiden_chars(char *line, int flag)
|
||||
int lm_check_forbiden_chars(char *line, int flag)
|
||||
{
|
||||
char *hash;
|
||||
char *dash;
|
||||
char *hash;
|
||||
char *dash;
|
||||
|
||||
if (line != NULL)
|
||||
{
|
||||
dash = ft_strchr(line, '-');
|
||||
hash = ft_strchr(line, '#');
|
||||
if (flag == 0 && dash == NULL
|
||||
&& hash == NULL)
|
||||
if (flag == 0 && dash == NULL && hash == NULL)
|
||||
return (1);
|
||||
if (flag == 1 && dash == NULL
|
||||
&& hash != NULL)
|
||||
if (flag == 1 && dash == NULL && hash != NULL)
|
||||
return (1);
|
||||
if (flag == 2 && dash == NULL
|
||||
if (flag == 2 && dash == NULL
|
||||
&& (hash == NULL || (hash != NULL && line[1] != '#')))
|
||||
return (1);
|
||||
if (flag == 3 && dash != NULL
|
||||
&& hash == NULL)
|
||||
if (flag == 3 && dash != NULL && hash == NULL)
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void lm_clear_unv(t_holder *holder)
|
||||
void lm_clear_unv(t_holder *holder)
|
||||
{
|
||||
t_temp *data;
|
||||
t_temp *flush;
|
||||
t_temp *data;
|
||||
t_temp *flush;
|
||||
|
||||
data = holder->data;
|
||||
while (data)
|
||||
@@ -64,24 +61,22 @@ void lm_clear_unv(t_holder *holder)
|
||||
holder->data = NULL;
|
||||
}
|
||||
|
||||
int lm_verify_links(t_holder *data, t_syntax *synt)
|
||||
int lm_verify_links(t_holder *data, t_syntax *synt)
|
||||
{
|
||||
if (!synt->l_error || (synt->l_error && data->count > 0))
|
||||
{
|
||||
ft_printf("Bingo\n");
|
||||
if (!synt->l_error || (synt->l_error && data->count > 0))
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int lm_verify_cmd(t_syntax *synt, t_holder *holder, t_lmdata *data)
|
||||
int lm_verify_cmd(t_syntax *synt, t_holder *holder
|
||||
, t_lmdata *data)
|
||||
{
|
||||
if (synt->s_cmd && synt->e_cmd
|
||||
&& !synt->e_error && !synt->s_error
|
||||
&& !synt->v_error
|
||||
&& synt->nb_state
|
||||
&& synt->nb_state
|
||||
&& lm_verify_links(holder, synt)
|
||||
&& (data->nb_nodes > 0))
|
||||
&& (data->nb_nodes > 0))
|
||||
return (1);
|
||||
lm_clear_unv(holder);
|
||||
return (0);
|
||||
|
||||
Reference in New Issue
Block a user