error for + case fix close #174

This commit is contained in:
Antoine Riard 2017-03-24 15:18:17 +01:00
parent 016d634515
commit b95476a0be
12 changed files with 23 additions and 40 deletions

View file

@ -6,7 +6,7 @@
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ # # By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2016/08/29 21:32:58 by wescande #+# #+# # # Created: 2016/08/29 21:32:58 by wescande #+# #+# #
# Updated: 2017/03/24 12:02:21 by gwojda ### ########.fr # # Updated: 2017/03/24 14:53:07 by ariard ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -65,7 +65,6 @@ completion/c_terminal.c\
completion/completion.c\ completion/completion.c\
exec/ast_free.c\ exec/ast_free.c\
exec/bad_fd.c\ exec/bad_fd.c\
exec/error_badidentifier.c\
exec/exec_ampersand.c\ exec/exec_ampersand.c\
exec/exec_and_if.c\ exec/exec_and_if.c\
exec/exec_bang.c\ exec/exec_bang.c\

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
/* Updated: 2017/03/23 16:27:10 by ariard ### ########.fr */ /* Updated: 2017/03/24 14:47:12 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -166,8 +166,6 @@ void *redir_copy(void *data);
void redir_free(void *data, size_t content_size); void redir_free(void *data, size_t content_size);
char **token_to_argv(t_ld *ld, int do_match); char **token_to_argv(t_ld *ld, int do_match);
int error_badidentifier(char *name);
t_btree *is_function(t_process *p); t_btree *is_function(t_process *p);
/* /*

View file

@ -1,5 +1,8 @@
case van in case van in
( "bus" ) echo Hello world ;; ( "bus" ) echo Hello world ;;
( "velo" ) echo Comment va ;; ( "velo" ) echo Comment va ;;
( "van" ) ls ;; ( "van" ) case tutu in
( toto ) pwd ;;
( tutu ) ls ;;
esac ;;
esac esac

View file

@ -1,21 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error_badidentifier.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/06 18:03:51 by ariard #+# #+# */
/* Updated: 2017/03/06 18:11:26 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int error_badidentifier(char *name)
{
ft_putstr_fd("`", 2);
ft_putstr(name);
ft_putstr_fd("' not a valid identifier", 2);
return (1);
}

View file

@ -6,12 +6,14 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/15 00:49:20 by wescande #+# #+# */ /* Created: 2017/03/15 00:49:20 by wescande #+# #+# */
/* Updated: 2017/03/22 22:20:02 by ariard ### ########.fr */ /* Updated: 2017/03/24 14:52:00 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
#define FORERR_0 ": `%s' not a valid identifier"
int plaunch_for(t_process *p) int plaunch_for(t_process *p)
{ {
t_ld *temp; t_ld *temp;
@ -22,7 +24,7 @@ int plaunch_for(t_process *p)
temp = p->data.d_for.token; temp = p->data.d_for.token;
var = ((char **)temp->content)[0]; var = ((char **)temp->content)[0];
if (!word_is_assignment(temp->content)) if (!word_is_assignment(temp->content))
return (error_badidentifier(var)); return (SH_ERR(FORERR_0, var));
i = 0; i = 0;
av = token_to_argv(temp, 1); av = token_to_argv(temp, 1);
while (av[++i]) while (av[++i])

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/26 00:07:05 by ariard #+# #+# */ /* Created: 2017/01/26 00:07:05 by ariard #+# #+# */
/* Updated: 2017/03/22 16:38:44 by gwojda ### ########.fr */ /* Updated: 2017/03/24 15:01:55 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -39,6 +39,7 @@ static int recognization_rvwords(t_token *pv_tk, t_token *at_tk)
|| pv_tk->type == TK_ELIF || pv_tk->type == TK_ELSE || pv_tk->type == TK_ELIF || pv_tk->type == TK_ELSE
|| pv_tk->type == TK_DSEMI || pv_tk->type == TK_PAREN_OPEN || pv_tk->type == TK_DSEMI || pv_tk->type == TK_PAREN_OPEN
|| pv_tk->type == TK_LBRACE || pv_tk->type == TK_UNTIL) || pv_tk->type == TK_LBRACE || pv_tk->type == TK_UNTIL)
|| pv_tk->type == TK_PAREN_CLOSE
|| (pv_tk->type == TK_PAREN_CLOSE && at_tk->type == TK_PAREN_OPEN)); || (pv_tk->type == TK_PAREN_CLOSE && at_tk->type == TK_PAREN_OPEN));
} }

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 19:12:50 by ariard #+# #+# */ /* Created: 2017/03/20 19:12:50 by ariard #+# #+# */
/* Updated: 2017/03/23 17:25:03 by ariard ### ########.fr */ /* Updated: 2017/03/24 14:49:17 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */ /* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
/* Updated: 2017/03/23 16:58:43 by ariard ### ########.fr */ /* Updated: 2017/03/24 14:55:27 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -43,6 +43,7 @@ static int handle_instruction(t_list **token, t_btree **ast)
return (ret); return (ret);
if (do_lexer_routine(token, stream) > 0) if (do_lexer_routine(token, stream) > 0)
continue ; continue ;
token_print(*token);
if ((ret = do_parser_routine(token, ast)) == 1 if ((ret = do_parser_routine(token, ast)) == 1
&& SH_NO_INTERACTIVE(data->opts)) && SH_NO_INTERACTIVE(data->opts))
return (ret); return (ret);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/04 20:42:13 by ariard #+# #+# */ /* Created: 2017/03/04 20:42:13 by ariard #+# #+# */
/* Updated: 2017/03/22 15:30:25 by ariard ### ########.fr */ /* Updated: 2017/03/24 15:17:40 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -62,12 +62,12 @@ int add_case_cmd(t_btree **ast, t_list **lst)
node->nest++; node->nest++;
if (token->type == TK_ESAC && (node->type == TK_PAREN_OPEN if (token->type == TK_ESAC && (node->type == TK_PAREN_OPEN
|| node->type == TK_CASE) && node->nest > 0) || node->type == TK_CASE) && node->nest > 0)
return ((node->nest--)); node->nest--;
else if (token->type == TK_DSEMI && node->type == TK_PAREN_OPEN else if (token->type == TK_DSEMI && node->type == TK_PAREN_OPEN
&& node->nest == 0) && node->nest == 0)
return ((node->full = 1)); return ((node->full = 1));
else if ((token->type == TK_ESAC) else if ((token->type == TK_ESAC) && node->nest == 0
&& node->nest == 0) && (node->type == TK_CASE || node->type == TK_PAREN_OPEN))
return ((node->full = 1)); return ((node->full = 1));
else if (token->type == TK_PAREN_CLOSE) else if (token->type == TK_PAREN_CLOSE)
return (0); return (0);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 18:32:59 by ariard #+# #+# */ /* Created: 2017/02/15 18:32:59 by ariard #+# #+# */
/* Updated: 2017/03/23 16:49:18 by ariard ### ########.fr */ /* Updated: 2017/03/24 15:01:36 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -84,7 +84,6 @@ int build_tree(t_btree **ast, t_list **lst)
i = 0; i = 0;
token = (*lst)->content; token = (*lst)->content;
check_cache(token, cache); check_cache(token, cache);
DG("new");
while (g_treematch[i].type) while (g_treematch[i].type)
{ {
if ((isseparator(token, cache) && g_treematch[i].type == token->type)) if ((isseparator(token, cache) && g_treematch[i].type == token->type))

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 16:17:38 by ariard #+# #+# */ /* Created: 2017/03/11 16:17:38 by ariard #+# #+# */
/* Updated: 2017/03/18 19:18:34 by ariard ### ########.fr */ /* Updated: 2017/03/24 15:02:51 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -49,6 +49,7 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser)
parser->state = SUCCESS; parser->state = SUCCESS;
else else
parser->state = UNDEFINED; parser->state = UNDEFINED;
btree_print(STDBUG, *ast, &ft_putast);
build_tree(ast, token); build_tree(ast, token);
if ((end_instruction(&parser->stack) && !(*token)->next)) if ((end_instruction(&parser->stack) && !(*token)->next))
insert_linebreak(token); insert_linebreak(token);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 18:57:44 by ariard #+# #+# */ /* Created: 2017/02/15 18:57:44 by ariard #+# #+# */
/* Updated: 2017/03/21 15:46:51 by jhalford ### ########.fr */ /* Updated: 2017/03/24 15:00:14 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */