From 52bb7cc0f234776cd19c7a608b06578150d4695a Mon Sep 17 00:00:00 2001 From: nass1pro Date: Mon, 20 Jul 2020 14:55:11 +0200 Subject: update eval_cmd --- src/parse/parse.c | 11 +++++-- src/parse/parse_error.c | 84 +------------------------------------------------ 2 files changed, 10 insertions(+), 85 deletions(-) (limited to 'src/parse') diff --git a/src/parse/parse.c b/src/parse/parse.c index 89102bc..29b3ccb 100644 --- a/src/parse/parse.c +++ b/src/parse/parse.c @@ -6,7 +6,7 @@ /* By: nahaddac +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/17 18:09:04 by nahaddac #+# #+# */ -/* Updated: 2020/07/19 19:25:29 by charles ### ########.fr */ +/* Updated: 2020/07/20 10:26:14 by nahaddac ### ########.fr */ /* */ /* ************************************************************************** */ @@ -47,6 +47,13 @@ t_ret *parse_redir(t_ftlst *input, t_ftlst **redirs) push_token(redirs, input->data); input = input->next; + if (input == NULL) + { + errorf("syntax error near unexpected token `newline'\n", NULL); + tmp = ret_wrap_ast(NULL, NULL); + tmp->syntax_error = true; + return tmp; + } tag = ((t_token *)input->data)->tag; while(input != NULL && input->next != NULL @@ -91,7 +98,7 @@ t_ret *parse_cmd(t_ftlst *input) else if (tag & TAG_IS_REDIR) { tmp = parse_redir(input, &ast->redirs); - if (tmp->syntax_error || tmp == NULL) + if (tmp == NULL || tmp->syntax_error) return tmp; input = tmp->rest; } diff --git a/src/parse/parse_error.c b/src/parse/parse_error.c index 42d46ea..84b06b2 100644 --- a/src/parse/parse_error.c +++ b/src/parse/parse_error.c @@ -6,90 +6,8 @@ /* By: nahaddac +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/06/18 15:09:48 by nahaddac #+# #+# */ -/* Updated: 2020/07/17 11:24:23 by nahaddac ### ########.fr */ +/* Updated: 2020/07/20 10:46:26 by nahaddac ### ########.fr */ /* */ /* ************************************************************************** */ #include "parser.h" - -// t_token *error_syntax_parent(t_ftlst *in) -// { -// t_token *tk; -// t_ftlst *first; -// -// first = in; -// while(in != NULL) -// { -// tk = in->data; -// if (tk->tag & TAG_PARENT_OPEN || tk->tag & TAG_PARENT_CLOSE) -// printf("%s\n", "coucouc"); -// in = in->next; -// } -// return first; -// } - -// int out_error_first(t_token *tk) -// { -// int i; -// -// i = 0; -// if(tk->tag & TAG_IS_SEP) -// return(1); -// if (tk->tag & TAG_IS_REDIR) -// { -// while(tk->content[i]) -// i++; -// if (tk->tag & TAG_REDIR_APPEND && i <= 2) -// return (0); -// else -// return(1); -// } -// return(0); -// } -// -// t_token *error_syntax_simple(t_ftlst *in) -// { -// t_token *tk; -// size_t i; -// /* t_ftlst *first; */ -// -// tk = in->data; -// /* first = in; */ -// if(tk->tag & TAG_IS_SEP || (tk->tag & TAG_IS_REDIR)) -// { -// if (out_error_first(tk)) -// { -// i = ft_strlen(tk->content); -// if (i >= 2) -// tk->content[2] = '\0'; -// tk->content = -// ft_strjoin3("minishell: syntax error near unexpected token `", -// tk->content, "'"); -// return(tk); -// } -// } -// while(in != NULL) -// { -// i = 0; -// tk = in->data; -// if(tk->tag & TAG_IS_SEP || (tk->tag & TAG_IS_REDIR)) -// { -// if (((t_token *)in->next->data)->tag & -// ((t_token*)in->next->data)->tag & TAG_IS_SEP || -// (((t_token*)in->next->data)->tag & TAG_IS_REDIR)) -// { -// tk = in->next->data; -// i = ft_strlen(tk->content); -// if (i >= 3) -// tk->content[2] = '\0'; -// tk->content = -// ft_strjoin3("minishell: syntax error near unexpected token `", -// tk->content, "'"); -// printf("%s\n",tk->content ); -// return(tk); -// } -// } -// in = in->next; -// } -// return 0; -// } -- cgit