assignement word as word if in second position

This commit is contained in:
Antoine Riard 2017-03-13 17:52:36 +01:00
parent 1a8f32286d
commit 5c2bb40bf6
12 changed files with 31 additions and 18 deletions

@ -1 +1 @@
Subproject commit 9382dc10fdb91892ab26604a5776e5301ab88b71
Subproject commit b209bb1fb718a68256253d5ab5ff69a46a90d5d6

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 11:39:37 by gwojda #+# #+# */
/* Updated: 2017/02/15 11:46:20 by gwojda ### ########.fr */
/* Updated: 2017/03/13 17:48:21 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -73,8 +73,8 @@ int handle_instruction(int fd)
}
}
btree_print(STDBUG, ast, &ft_putast);
// if (ft_exec(&ast))
// return (1);
if (ft_exec(&ast))
return (1);
instruction_free(&token, &parser, &ast);
if (SH_IS_INTERACTIVE(data_singleton()->opts) && *lexer.str)
ft_add_str_in_history(lexer.str);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/04 20:42:13 by ariard #+# #+# */
/* Updated: 2017/03/13 16:26:28 by ariard ### ########.fr */
/* Updated: 2017/03/13 17:32:22 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 20:49:15 by ariard #+# #+# */
/* Updated: 2017/03/13 14:37:18 by ariard ### ########.fr */
/* Updated: 2017/03/13 17:37:50 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/17 16:39:05 by ariard #+# #+# */
/* Updated: 2017/03/13 16:57:59 by ariard ### ########.fr */
/* Updated: 2017/03/13 16:59:01 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/03 15:08:16 by ariard #+# #+# */
/* Updated: 2017/03/11 15:56:38 by ariard ### ########.fr */
/* Updated: 2017/03/13 17:36:24 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 15:58:38 by ariard #+# #+# */
/* Updated: 2017/03/13 16:26:59 by ariard ### ########.fr */
/* Updated: 2017/03/13 17:29:05 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 18:32:59 by ariard #+# #+# */
/* Updated: 2017/03/13 14:37:11 by ariard ### ########.fr */
/* Updated: 2017/03/13 17:45:41 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -63,6 +63,16 @@ static int isseparator(t_token *token, int cache)
return (1);
}
static int check_cache(t_token *token, int cache)
{
if (token->type == TK_ASSIGNEMENT_WORD && cache == TK_WORD)
token->type = TK_WORD;
if (token->type == TK_PAREN_OPEN && cache != TK_IN && cache != TK_DSEMI
&& cache != TK_WORD)
token->type = SUBSHELL;
return (0);
}
int build_tree(t_btree **ast, t_list **lst)
{
int i;
@ -71,9 +81,7 @@ int build_tree(t_btree **ast, t_list **lst)
i = 0;
token = (*lst)->content;
if (token->type == TK_PAREN_OPEN && cache != TK_IN && cache != TK_DSEMI
&& cache != TK_WORD)
token->type = SUBSHELL;
check_cache(token, cache);
while (g_treematch[i].type)
{
if ((isseparator(token, cache) && g_treematch[i].type == token->type))

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 16:11:21 by ariard #+# #+# */
/* Updated: 2017/03/13 16:39:28 by ariard ### ########.fr */
/* Updated: 2017/03/13 17:28:13 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 16:17:38 by ariard #+# #+# */
/* Updated: 2017/03/11 16:32:15 by ariard ### ########.fr */
/* Updated: 2017/03/13 17:42:06 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -35,6 +35,7 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser)
{
t_sym *head;
(void)ast;
if (pop_heredoc(token))
return (0);
while (*token)
@ -61,7 +62,7 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser)
else
ft_lst_delif(token, (*token)->content, &ft_addrcmp, &token_free);
}
// if (parser->state == SUCCESS)
// DG("sucessful parsing");
if (parser->state == SUCCESS)
DG("sucessful parsing");
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 17:58:34 by ariard #+# #+# */
/* Updated: 2017/03/13 16:31:42 by ariard ### ########.fr */
/* Updated: 2017/03/13 17:30:53 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -68,6 +68,10 @@ t_prodmatch g_prodmatch[] =
{TK_ASSIGNEMENT_WORD, TK_ELIF, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, TK_ELSE, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, NEWLINE_LIST, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, CMD_NAME, CMD_SUFFIX},
{TK_ASSIGNEMENT_WORD, CMD_SUPERIOR, CMD_SUFFIX},
{TK_ASSIGNEMENT_WORD, PIPE_SEMI_SEQUENCE, CMD_SUFFIX},
{TK_ASSIGNEMENT_WORD, CMD_WORD, CMD_SUFFIX},
{TK_NAME, TK_BANG, FNAME},
{TK_NAME, LINEBREAK, FNAME},
{TK_NAME, TK_PAREN_OPEN, FNAME},