diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index 383a14c9..59e15890 100644 --- a/42sh/includes/minishell.h +++ b/42sh/includes/minishell.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */ -/* Updated: 2017/03/02 17:15:12 by jhalford ### ########.fr */ +/* Updated: 2017/03/04 16:46:52 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -42,6 +42,7 @@ # define SH_MODE_MASK (SH_MODE_INPUT | SH_MODE_EXEC) # define SH_HAS_JOBC(b) (b & SH_OPTS_JOBC) # define SH_IS_INTERACTIVE(b) (b & SH_INTERACTIVE) +# define SH_NO_INTERACTIVE(b) !(b & SH_INTERACTIVE) # define SH_MSG_NOJOBC "no job-control" diff --git a/42sh/src/lexer/lexer_init.c b/42sh/src/lexer/lexer_init.c index 2c4a0c2f..799a52db 100644 --- a/42sh/src/lexer/lexer_init.c +++ b/42sh/src/lexer/lexer_init.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/21 16:14:08 by ariard #+# #+# */ -/* Updated: 2017/02/21 16:19:34 by ariard ### ########.fr */ +/* Updated: 2017/03/04 16:32:15 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/line-editing/readline.c b/42sh/src/line-editing/readline.c index 6d8f7f48..770d2163 100644 --- a/42sh/src/line-editing/readline.c +++ b/42sh/src/line-editing/readline.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ -/* Updated: 2017/03/03 18:29:03 by wescande ### ########.fr */ +/* Updated: 2017/03/04 16:50:05 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/instruction_free.c b/42sh/src/main/instruction_free.c index 4864e2ce..5f27155a 100644 --- a/42sh/src/main/instruction_free.c +++ b/42sh/src/main/instruction_free.c @@ -3,6 +3,7 @@ int instruction_free(t_list **token, t_parser *parser, t_btree **ast) { ft_lstdel(token, &token_free); + token = NULL; ft_lstdel(&parser->stack, NULL); btree_del(ast, &ast_free); return (0); diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 9a53abbc..b1bedc83 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/03 20:05:06 by ariard ### ########.fr */ +/* Updated: 2017/03/04 16:49:23 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,11 +36,14 @@ int handle_instruction(int fd) return (parser.state == UNDEFINED ? error_EOF(&token, &parser, &ast) : 1); } + DG("after readline %s", str); + DG("in lexer %s", lexer.str); ft_strappend(&lexer.str, str); if (get_lexer_stack(lexer) == BACKSLASH) pop(&lexer.stack); else if (get_lexer_stack(lexer) == DLESS) lexer.state = DLESS; + DG("after readline %s", lexer.str); ltoken = ft_lstlast(token); if (lexer_lex(token ? <oken : &token, &lexer)) return (1); @@ -56,7 +59,7 @@ int handle_instruction(int fd) continue ; if (parser.state == SUCCESS) break ; - else if (parser.state == ERROR && !SH_IS_INTERACTIVE(data_singleton()->opts)) + else if (parser.state == ERROR && SH_IS_INTERACTIVE(data_singleton()->opts)) return (error_syntax(&token, &parser, &ast)); else if (parser.state == ERROR) error_syntax(&token, &parser, &ast); diff --git a/42sh/src/parser/aggregate_sym.c b/42sh/src/parser/aggregate_sym.c index 5bb0d31a..03ae7a56 100644 --- a/42sh/src/parser/aggregate_sym.c +++ b/42sh/src/parser/aggregate_sym.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 17:39:18 by ariard #+# #+# */ -/* Updated: 2017/03/03 16:35:04 by ariard ### ########.fr */ +/* Updated: 2017/03/04 16:16:23 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -127,6 +127,7 @@ t_aggrematch g_aggrematch[] = {CMD_SUFFIX, CMD_WORD, SIMPLE_COMMAND, CMD_PREFIX}, {CMD_SUFFIX, CMD_NAME, SIMPLE_COMMAND, CMD_NAME}, {CMD_SUFFIX, CMD_SUPERIOR, CMD_SUPERIOR, CMD_SUPERIOR}, + {CMD_SUFFIX, PIPE_SEMI_SEQUENCE, PIPE_SEMI_SEQUENCE, PIPE_SEMI_SEQUENCE}, //to abstract {CMD_PREFIX, LINEBREAK, SIMPLE_COMMAND, 0}, {CMD_PREFIX, TK_PAREN_OPEN, SIMPLE_COMMAND, 0}, diff --git a/42sh/src/parser/error_syntax.c b/42sh/src/parser/error_syntax.c index 470c3b87..fd27abe1 100644 --- a/42sh/src/parser/error_syntax.c +++ b/42sh/src/parser/error_syntax.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 20:15:35 by ariard #+# #+# */ -/* Updated: 2017/03/03 14:27:52 by ariard ### ########.fr */ +/* Updated: 2017/03/04 16:50:44 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -75,12 +75,12 @@ int error_syntax(t_list **lst, t_parser *parser, instruction_free(lst, parser, ast); if (temp == 0) ft_putstr_fd("grammar error, notify ariard", 2); - return (1); + return (0); } int error_EOF(t_list **lst, t_parser *parser, t_btree **ast) { ft_putstr_fd("syntax error near unexpected EOF", 2); instruction_free(lst, parser, ast); - return (1); + return (0); } diff --git a/42sh/src/parser/eval_sym.c b/42sh/src/parser/eval_sym.c index 81a62e54..9acbc37a 100644 --- a/42sh/src/parser/eval_sym.c +++ b/42sh/src/parser/eval_sym.c @@ -569,6 +569,7 @@ t_stackmatch g_stackmatch[] = {CMD_SUFFIX, CMD_WORD}, {CMD_SUFFIX, CMD_NAME}, {CMD_SUFFIX, CMD_SUPERIOR}, + {CMD_SUFFIX, PIPE_SEMI_SEQUENCE}, {CMD_PREFIX, LINEBREAK}, {CMD_PREFIX, TK_PAREN_OPEN}, {CMD_PREFIX, TK_LBRACE},