orphan backquotes and orpan parens generate parse errors
This commit is contained in:
parent
073ef322e4
commit
b08b727779
9 changed files with 29 additions and 10 deletions
1
42sh/.gitignore
vendored
1
42sh/.gitignore
vendored
|
|
@ -3,4 +3,5 @@ minishell
|
|||
42sh
|
||||
out
|
||||
debug
|
||||
.42sh_history
|
||||
*.dSYM
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/02 14:55:46 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/02/02 15:14:58 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/09 16:25:06 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/02/02 15:04:48 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/02 14:49:49 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/02/02 15:04:50 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/12 14:01:59 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/02 14:52:30 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/02/02 15:16:25 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/11 16:11:11 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/02 14:54:57 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/02/02 15:22:34 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,13 +15,26 @@
|
|||
int ft_post_tokenize(t_list **alst, char **str)
|
||||
{
|
||||
int ret;
|
||||
t_flag tk;
|
||||
|
||||
while ((ret = reduce_parens(alst, *str)))
|
||||
if (ret == -1)
|
||||
{
|
||||
ft_dprintf(2, "{red}%s: parse error near '('{eoc}\n", SHELL_NAME);
|
||||
return (-1);
|
||||
}
|
||||
tk = TK_PAREN_CLOSE;
|
||||
if (ft_lst_find(*alst, &tk, token_cmp_type))
|
||||
{
|
||||
ft_dprintf(2, "{red}%s: parse error near ')'{eoc}\n", SHELL_NAME);
|
||||
return (-1);
|
||||
}
|
||||
while ((ret = reduce_bquotes(alst, str)))
|
||||
if (ret == -1)
|
||||
{
|
||||
ft_dprintf(2, "{red}%s: parse error near '`'{eoc}\n", SHELL_NAME);
|
||||
return (-1);
|
||||
}
|
||||
DG("new command from bquotes: '%s'", *str);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/11 16:46:27 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/02 14:52:28 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/02/02 15:16:24 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -24,10 +24,12 @@ int reduce_bquotes(t_list **alst, char **str)
|
|||
char *bq_end;
|
||||
|
||||
tk = TK_BQUOTE;
|
||||
DG("check 0");
|
||||
if ((start = ft_lst_find(*alst, &tk, token_cmp_type)))
|
||||
{
|
||||
DG("check 1");
|
||||
end = &start->next;
|
||||
while (end)
|
||||
while (end && *end)
|
||||
{
|
||||
token = (*end)->content;
|
||||
if (token->type == TK_BQUOTE)
|
||||
|
|
@ -35,7 +37,10 @@ int reduce_bquotes(t_list **alst, char **str)
|
|||
end = &(*end)->next;
|
||||
}
|
||||
if (!*end)
|
||||
{
|
||||
DG("check 42");
|
||||
return (-1);
|
||||
}
|
||||
bq_start = ((t_token*)start->content)->data;
|
||||
bq_end = ((t_token*)(*end)->content)->data;
|
||||
ft_lstdel(end, token_free);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/11 16:13:31 by jhalford #+# #+# */
|
||||
/* Updated: 2017/01/12 13:50:10 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/02/02 15:19:02 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/02 14:55:29 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/02/02 15:22:00 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ int main(int ac, char **av)
|
|||
{
|
||||
if (ft_readline())
|
||||
return (1);
|
||||
if (shell_single_command(ft_strdup(data_singleton()->line.input)))
|
||||
if (shell_single_command(ft_strdup(data_singleton()->line.input)) < 0)
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
|
|
|
|||
Loading…
Reference in a new issue