correctif encore

This commit is contained in:
Antoine Riard 2017-03-29 15:55:50 +02:00
parent 4a55e698ef
commit 6ff30f8293
6 changed files with 16 additions and 16 deletions

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/22 17:22:51 by ariard #+# #+# */
/* Updated: 2017/03/29 13:29:26 by ariard ### ########.fr */
/* Updated: 2017/03/29 15:42:45 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -32,6 +32,7 @@ struct s_parser
t_list *stack;
t_sym *new_sym;
t_list *heredoc_queue;
int cache;
};
struct s_aggrematch
@ -89,7 +90,7 @@ struct s_treematch
int (*add)(t_btree **ast, t_list **lst);
};
int build_tree(t_btree **ast, t_list **lst);
int build_tree(t_btree **ast, t_list **lst, t_parser *parser);
int add_sep(t_btree **ast, t_list **lst);
int add_cmd(t_btree **ast, t_list **lst);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 18:32:59 by ariard #+# #+# */
/* Updated: 2017/03/29 13:28:38 by ariard ### ########.fr */
/* Updated: 2017/03/29 15:40:57 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -77,20 +77,20 @@ static int check_cache(t_token *token, int cache)
return (0);
}
int build_tree(t_btree **ast, t_list **lst)
int build_tree(t_btree **ast, t_list **lst, t_parser *parser)
{
int i;
static int cache;
// static int cache;
t_token *token;
i = 0;
token = (*lst)->content;
check_cache(token, cache);
check_cache(token, parser->cache);
while (g_treematch[i].type)
{
if ((isseparator(token, cache) && g_treematch[i].type == token->type))
if ((isseparator(token, parser->cache) && g_treematch[i].type == token->type))
{
cache = token->type;
parser->cache = token->type;
return (g_treematch[i].add(ast, lst));
}
i++;

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 16:11:21 by ariard #+# #+# */
/* Updated: 2017/03/29 15:31:27 by ariard ### ########.fr */
/* Updated: 2017/03/29 15:52:29 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -1245,20 +1245,17 @@ static t_stackmatch g_stackmatch[] =
{PIPELINE, SEPARATOR_OP},
{PIPELINE, AND_OR},
{PIPELINE, NEWLINE_LIST},
{AND_OR, TK_DO},
{AND_OR, TK_PAREN_CLOSE},
{AND_OR, TK_WHILE},
{AND_OR, TK_UNTIL},
{AND_OR, TK_IF},
{AND_OR, TK_ELIF},
{AND_OR, TK_THEN},
{AND_OR, TK_ELSE},
{AND_OR, CMD_SUPERIOR},
{AND_OR, COMPOUND_LIST},
{AND_OR, PIPE_SEMI_SEQUENCE},
{AND_OR, PIPE_CLOSE_SEQUENCE},
{AND_OR, CASE_LIST_NS},
{AND_OR, COMPLETE_CONDITION},
{AND_OR, CONDITION},
{AND_OR, LINEBREAK},
{AND_OR, TK_BANG},

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 16:17:38 by ariard #+# #+# */
/* Updated: 2017/03/29 15:32:27 by ariard ### ########.fr */
/* Updated: 2017/03/29 15:43:05 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -49,7 +49,7 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser)
parser->state = SUCCESS;
else
parser->state = UNDEFINED;
build_tree(ast, token);
build_tree(ast, token, parser);
if ((end_instruction(&parser->stack) && !(*token)->next))
insert_linebreak(token);
else

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/16 19:30:17 by ariard #+# #+# */
/* Updated: 2017/03/29 13:29:01 by ariard ### ########.fr */
/* Updated: 2017/03/29 15:42:05 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,4 +19,5 @@ void parser_destroy(t_parser *parser)
ft_lstdel(&parser->heredoc_queue, &ft_lst_cfree);
free(parser->new_sym);
parser->new_sym = NULL;
parser->cache = 0;
}

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/21 16:14:04 by ariard #+# #+# */
/* Updated: 2017/03/29 13:27:45 by ariard ### ########.fr */
/* Updated: 2017/03/29 15:43:52 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -16,6 +16,7 @@ void parser_init(t_parser *parser)
{
parser->state = SUCCESS;
parser->new_sym = NULL;
parser->cache = 0;
parser->stack = NULL;
parser->heredoc_queue = NULL;
}