diff --git a/42sh/src/lexer/lexer_while.c b/42sh/src/lexer/lexer_while.c new file mode 100644 index 00000000..476205af --- /dev/null +++ b/42sh/src/lexer/lexer_while.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lexer_loop.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ariard +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/01/25 21:58:12 by ariard #+# #+# */ +/* Updated: 2017/01/26 00:58:57 by ariard ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "lexer.h" + +int lexer_while(t_list **alst, char *str) +{ + t_token *token; + + token = (*alst)->content; + if (ft_strncmp(str, "while", 5) == 0) + token->type = TK_WHILE; + else if (ft_isalnum(*str)) + { + token_append(token, *str); + return (ft_tokenize(alst, str + 1, WORD)); + } + return (ft_tokenize(&(*alst)->next, str + 6, LIST)); +}