diff --git a/42sh/includes/exec.h b/42sh/includes/exec.h index ead042eb..67e47330 100644 --- a/42sh/includes/exec.h +++ b/42sh/includes/exec.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ -/* Updated: 2017/02/06 22:34:37 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:09:05 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/includes/lexer.h b/42sh/includes/lexer.h index 29e75b4b..7f27f77e 100644 --- a/42sh/includes/lexer.h +++ b/42sh/includes/lexer.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */ -/* Updated: 2017/02/06 16:22:01 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:29:39 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,6 +44,7 @@ typedef long long t_type; enum e_lexstate { DEFAULT, + NEWLINE, DELIM, SEP, WORD, @@ -57,6 +58,7 @@ enum e_lexstate BACKSLASH, VAR, SPECIAL, + COMMENT, }; struct s_token diff --git a/42sh/includes/parser.h b/42sh/includes/parser.h index f5eae463..47b850e1 100644 --- a/42sh/includes/parser.h +++ b/42sh/includes/parser.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/01 12:15:54 by jhalford #+# #+# */ -/* Updated: 2017/02/03 14:01:51 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:09:20 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_command.c b/42sh/src/exec/exec_command.c index 995fbca6..49bdfc0e 100644 --- a/42sh/src/exec/exec_command.c +++ b/42sh/src/exec/exec_command.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */ -/* Updated: 2017/02/06 15:31:42 by wescande ### ########.fr */ +/* Updated: 2017/02/07 12:14:31 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/launch_process.c b/42sh/src/exec/launch_process.c index 2c8577ed..c0cb312f 100644 --- a/42sh/src/exec/launch_process.c +++ b/42sh/src/exec/launch_process.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:20:45 by jhalford #+# #+# */ -/* Updated: 2017/02/06 16:08:09 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:11:34 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/process_setexec.c b/42sh/src/exec/process_setexec.c index 2ce1d0a3..be358b0e 100644 --- a/42sh/src/exec/process_setexec.c +++ b/42sh/src/exec/process_setexec.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 17:07:10 by jhalford #+# #+# */ -/* Updated: 2017/01/11 18:01:36 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:07:43 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/ft_tokenize.c b/42sh/src/lexer/ft_tokenize.c index 3fe3504c..92cc33a8 100644 --- a/42sh/src/lexer/ft_tokenize.c +++ b/42sh/src/lexer/ft_tokenize.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */ -/* Updated: 2017/02/03 15:39:53 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:29:41 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,6 +15,7 @@ int (*g_lexer[])(t_list **alst, char *str) = { &lexer_default, + &lexer_newline, &lexer_delim, &lexer_sep, &lexer_word, @@ -28,6 +29,7 @@ int (*g_lexer[])(t_list **alst, char *str) = &lexer_backslash, &lexer_var, &lexer_special, + &lexer_comment, }; int ft_is_delim(char c) diff --git a/42sh/src/lexer/get_lexer_state.c b/42sh/src/lexer/get_lexer_state.c index 37ae772b..bb2dbc18 100644 --- a/42sh/src/lexer/get_lexer_state.c +++ b/42sh/src/lexer/get_lexer_state.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/10 13:45:46 by jhalford #+# #+# */ -/* Updated: 2017/01/11 15:48:13 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:16:51 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,8 @@ t_lexstate get_lexer_state(char *str) { if (ft_is_delim(*str)) return (DELIM); + else if (*str == '#') + return (COMMENT); else if (*str == '$') return (VAR); else if (*str == '&' || *str == ';' || *str == '|') diff --git a/42sh/src/lexer/lexer_dquote.c b/42sh/src/lexer/lexer_dquote.c index 56a49ab2..9b64b6a6 100644 --- a/42sh/src/lexer/lexer_dquote.c +++ b/42sh/src/lexer/lexer_dquote.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 18:36:58 by jhalford #+# #+# */ -/* Updated: 2017/01/27 15:53:31 by wescande ### ########.fr */ +/* Updated: 2017/02/07 12:22:23 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_newline.c b/42sh/src/lexer/lexer_newline.c new file mode 100644 index 00000000..2f0300f6 --- /dev/null +++ b/42sh/src/lexer/lexer_newline.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lexer_newline.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ariard +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/01/23 23:19:46 by ariard #+# #+# */ +/* Updated: 2017/02/07 12:37:17 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "lexer.h" + +int lexer_newline(t_list **alst, char *str) +{ + t_token *token; + + if (*alst) + { + token = (*alst)->content; + if (*token->data) + return (lexer_newline(&(*alst)->next, str)); + } + else + { + token = token_init(); + *alst = ft_lstnew(token, sizeof(*token)); + } + token = (*alst)->content; + token->type = TK_NEWLINE; + return (ft_tokenize(&(*alst)->next, str + 1, DEFAULT)); +} diff --git a/42sh/src/lexer/lexer_var.c b/42sh/src/lexer/lexer_var.c index b02b71ac..fc9c98d7 100644 --- a/42sh/src/lexer/lexer_var.c +++ b/42sh/src/lexer/lexer_var.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/10 14:54:57 by jhalford #+# #+# */ -/* Updated: 2017/02/06 14:02:20 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:16:37 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_word.c b/42sh/src/lexer/lexer_word.c index e0081f8b..c89e4f63 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/01/30 13:08:16 by wescande ### ########.fr */ +/* Updated: 2017/02/07 12:16:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/token_print.c b/42sh/src/lexer/token_print.c index 343fe5bc..cc644557 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/01/27 21:57:05 by wescande ### ########.fr */ +/* Updated: 2017/02/07 12:11:24 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/parser/parse_word.c b/42sh/src/parser/parse_word.c index 60535449..1bb12b7d 100644 --- a/42sh/src/parser/parse_word.c +++ b/42sh/src/parser/parse_word.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 12:49:45 by jhalford #+# #+# */ -/* Updated: 2017/02/02 14:24:53 by jhalford ### ########.fr */ +/* Updated: 2017/02/07 12:11:11 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */