From 5d07da9fb3743638c273b21e8a2d5ad3a2252e99 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Fri, 24 Mar 2017 19:44:04 +0100 Subject: [PATCH] close #189 close #190 --- 42sh/src/exec/exec_var.c | 3 ++- 42sh/src/parser/add_cmd.c | 4 ++-- 42sh/src/parser/aggregate_sym.c | 9 +++++---- 42sh/src/parser/eval_sym.c | 5 +++-- 42sh/src/parser/ft_parse.c | 3 ++- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/42sh/src/exec/exec_var.c b/42sh/src/exec/exec_var.c index 4a227eb0..2660bef4 100644 --- a/42sh/src/exec/exec_var.c +++ b/42sh/src/exec/exec_var.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/07 11:12:05 by ariard #+# #+# */ -/* Updated: 2017/03/24 15:40:00 by ariard ### ########.fr */ +/* Updated: 2017/03/24 19:43:40 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,5 +29,6 @@ int exec_var(t_btree **ast) value = equal ? equal + 1 : NULL; builtin_setenv("internal", (char*[]){"local", var, value, 0}, NULL); ft_sstrfree(av); + ft_exec(&(*ast)->right); return (0); } diff --git a/42sh/src/parser/add_cmd.c b/42sh/src/parser/add_cmd.c index 3465e91c..b1c71b6e 100644 --- a/42sh/src/parser/add_cmd.c +++ b/42sh/src/parser/add_cmd.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 20:49:15 by ariard #+# #+# */ -/* Updated: 2017/03/24 16:56:50 by ariard ### ########.fr */ +/* Updated: 2017/03/24 19:25:02 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -59,7 +59,7 @@ static int emblematic_token(t_btree **ast, t_list **lst) return (0); if (node->type != TK_DO && node->type != TK_THEN && node->type != CMD && node->type != REDIR - && node->type != TK_ASSIGNMENT_WORD && node->type != TK_FOR) + && node->type != TK_FOR) return (1); } return (0); diff --git a/42sh/src/parser/aggregate_sym.c b/42sh/src/parser/aggregate_sym.c index a3b7519b..0a2dd092 100644 --- a/42sh/src/parser/aggregate_sym.c +++ b/42sh/src/parser/aggregate_sym.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/11 15:58:38 by ariard #+# #+# */ -/* Updated: 2017/03/24 19:09:05 by ariard ### ########.fr */ +/* Updated: 2017/03/24 19:26:26 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -380,18 +380,15 @@ int aggregate_sym(t_list **stack, t_sym *new_sym, t_parstate *state) return (1); i = -1; head = (*stack)->content; - DG("aggregate head %s && sym %s", read_state(*head), read_state(*new_sym)); while (g_aggrematch[++i].top) if (*new_sym == g_aggrematch[i].top && MATCH_STACK(*head, g_aggrematch[i].under)) { - DG("MATH: %s", read_state(g_aggrematch[i].new_sym)); *new_sym = g_aggrematch[i].new_sym; if (g_aggrematch[i].erase_sym) { pop_stack(stack, g_aggrematch[i].erase_sym); head = (*stack)->content; - DG("stack after pop %s", read_state(*head)); } if (eval_sym(stack, *new_sym) && !(*state = ERROR)) return (1); @@ -400,3 +397,7 @@ int aggregate_sym(t_list **stack, t_sym *new_sym, t_parstate *state) } return (0); } + +// DG("aggregate head %s && sym %s", read_state(*head), read_state(*new_sym)); +// DG("MATH: %s", read_state(g_aggrematch[i].new_sym)); +// DG("stack after pop %s", read_state(*head)); diff --git a/42sh/src/parser/eval_sym.c b/42sh/src/parser/eval_sym.c index f3483d14..dfd9e6cb 100644 --- a/42sh/src/parser/eval_sym.c +++ b/42sh/src/parser/eval_sym.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/11 16:11:21 by ariard #+# #+# */ -/* Updated: 2017/03/24 19:11:10 by ariard ### ########.fr */ +/* Updated: 2017/03/24 19:25:44 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -1288,7 +1288,6 @@ int eval_sym(t_list **stack, t_sym new_sym) return (1); head = (*stack)->content; i = 0; - DG("eval head %s && sym %s", read_state(*head), read_state(new_sym)); while (g_stackmatch[i].top) { if (new_sym == g_stackmatch[i].top && *head == g_stackmatch[i].under) @@ -1297,3 +1296,5 @@ int eval_sym(t_list **stack, t_sym new_sym) } return (1); } + +//DG("eval head %s && sym %s", read_state(*head), read_state(new_sym)); diff --git a/42sh/src/parser/ft_parse.c b/42sh/src/parser/ft_parse.c index 08d51084..6d544b9a 100644 --- a/42sh/src/parser/ft_parse.c +++ b/42sh/src/parser/ft_parse.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/11 16:17:38 by ariard #+# #+# */ -/* Updated: 2017/03/24 17:01:05 by ariard ### ########.fr */ +/* Updated: 2017/03/24 19:26:48 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -49,6 +49,7 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser) parser->state = SUCCESS; else parser->state = UNDEFINED; + btree_print(STDBUG, *ast, &ft_putast); build_tree(ast, token); if ((end_instruction(&parser->stack) && !(*token)->next)) insert_linebreak(token);