diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index deac19e8..9b20a56e 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/07 21:13:31 by wescande ### ########.fr */ +/* Updated: 2017/03/08 12:05:37 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_delim.c b/42sh/src/lexer/lexer_delim.c index d67b61d5..72b7c47c 100644 --- a/42sh/src/lexer/lexer_delim.c +++ b/42sh/src/lexer/lexer_delim.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 11:58:44 by jhalford #+# #+# */ -/* Updated: 2017/03/05 17:08:23 by ariard ### ########.fr */ +/* Updated: 2017/03/08 12:09:52 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_end.c b/42sh/src/lexer/lexer_end.c index 4e3be646..5e0b6710 100644 --- a/42sh/src/lexer/lexer_end.c +++ b/42sh/src/lexer/lexer_end.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/05 16:58:24 by jhalford #+# #+# */ -/* Updated: 2017/03/05 17:29:17 by jhalford ### ########.fr */ +/* Updated: 2017/03/08 12:12:40 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_great.c b/42sh/src/lexer/lexer_great.c index 6e582bdc..f6f6a262 100644 --- a/42sh/src/lexer/lexer_great.c +++ b/42sh/src/lexer/lexer_great.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 12:06:35 by jhalford #+# #+# */ -/* Updated: 2017/03/05 18:20:02 by wescande ### ########.fr */ +/* Updated: 2017/03/08 12:10:46 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_less.c b/42sh/src/lexer/lexer_less.c index 9d08611c..02e1ee54 100644 --- a/42sh/src/lexer/lexer_less.c +++ b/42sh/src/lexer/lexer_less.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 12:06:53 by jhalford #+# #+# */ -/* Updated: 2017/03/05 18:19:48 by wescande ### ########.fr */ +/* Updated: 2017/03/08 12:10:38 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_lessand.c b/42sh/src/lexer/lexer_lessand.c index f7d30d45..3930c001 100644 --- a/42sh/src/lexer/lexer_lessand.c +++ b/42sh/src/lexer/lexer_lessand.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 11:58:51 by jhalford #+# #+# */ -/* Updated: 2017/03/05 18:05:39 by wescande ### ########.fr */ +/* Updated: 2017/03/08 12:12:01 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_paren.c b/42sh/src/lexer/lexer_paren.c index 735e56fe..5abf4b69 100644 --- a/42sh/src/lexer/lexer_paren.c +++ b/42sh/src/lexer/lexer_paren.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/03 17:37:15 by jhalford #+# #+# */ -/* Updated: 2017/03/05 16:48:06 by ariard ### ########.fr */ +/* Updated: 2017/03/08 12:14:09 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,7 @@ int lexer_paren(t_list **alst, t_lexer *lexer) token = (*alst)->content; if (token->type) - lexer_lex(&(*alst)->next, lexer); + return (lexer_lex(&(*alst)->next, lexer)); if (lexer->str[lexer->pos] == '(') { token->type = TK_PAREN_OPEN; diff --git a/42sh/src/lexer/lexer_sep.c b/42sh/src/lexer/lexer_sep.c index 6420498f..b44b41c5 100644 --- a/42sh/src/lexer/lexer_sep.c +++ b/42sh/src/lexer/lexer_sep.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/30 16:29:57 by jhalford #+# #+# */ -/* Updated: 2017/03/07 20:26:36 by ariard ### ########.fr */ +/* Updated: 2017/03/08 12:20:30 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,26 +19,20 @@ int lexer_sep(t_list **alst, t_lexer *lexer) char cn; lexer->state = DEFAULT; - if (*alst) - { - token = (*alst)->content; - if (*token->data) - return (lexer_sep(&(*alst)->next, lexer)); - } - else - { - token = token_init(); - *alst = ft_lstnew(token, sizeof(*token)); - } token = (*alst)->content; + if (token->type) + return (lexer_lex(&(*alst)->next, lexer)); c = lexer->str[lexer->pos]; - cn = lexer->str[lexer->pos + 1]; + lexer->pos++; + cn = lexer->str[lexer->pos]; if (c == '&') token->type = cn == '&' ? TK_AND_IF : TK_AMP; else if (c == '|') token->type = cn == '|' ? TK_OR_IF : TK_PIPE; - token->type = (c == ';') ? TK_SEMI : token->type; - token->type = (c == ';') && (cn == ';') ? TK_DSEMI : token->type; - lexer->pos += 1 + (token->type & (TK_AND_IF | TK_OR_IF | TK_DSEMI) ? 1 : 0); + else if (c == ';') + token->type = cn == ';' ? TK_DSEMI : TK_SEMI; + if (token->type == TK_AND_IF || token->type == TK_OR_IF + || token->type == TK_DSEMI) + lexer->pos++; return (lexer_lex(&(*alst)->next, lexer)); } diff --git a/42sh/src/lexer/lexer_word.c b/42sh/src/lexer/lexer_word.c index d5ad413c..b3e8aea4 100644 --- a/42sh/src/lexer/lexer_word.c +++ b/42sh/src/lexer/lexer_word.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 12:07:11 by jhalford #+# #+# */ -/* Updated: 2017/03/07 21:00:18 by wescande ### ########.fr */ +/* Updated: 2017/03/08 12:10:37 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/token_print.c b/42sh/src/lexer/token_print.c index c4529027..c17e1605 100644 --- a/42sh/src/lexer/token_print.c +++ b/42sh/src/lexer/token_print.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:39:01 by jhalford #+# #+# */ -/* Updated: 2017/03/05 16:27:58 by jhalford ### ########.fr */ +/* Updated: 2017/03/08 12:14:32 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ void token_print(t_list *lst) if (lst->content) token = lst->content; if (token->type) - DG("token : %s data [%s]\n", read_state(token->type), token->data); + DG("token : %s data [%s]", read_state(token->type), token->data); lst = lst->next; } } diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 0527cf28..e20fcf4f 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/07 21:53:23 by ariard ### ########.fr */ +/* Updated: 2017/03/08 12:20:37 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */