42-archive/42sh/src/lexer/lexer_greatand.c
2017-02-10 00:38:45 +01:00

36 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lexer_greatand.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 11:56:58 by jhalford #+# #+# */
/* Updated: 2017/02/09 19:56:40 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "lexer.h"
int lexer_greatand(t_list **alst, t_lexer *lexer)
{
t_token *token;
token = (*alst)->content;
token->type = TK_GREATAND;
if (ft_isdigit(lexer->str[lexer->pos]))
{
token_append(token, lexer, 0, 0);
lexer->str++;
return (lexer_greatand(alst, lexer));
}
else if (lexer->str[lexer->pos] == '-')
{
token_append(token, lexer, 0, 0);
lexer->str++;
lexer->state = DEFAULT;
return (lexer_lex(&(*alst)->next, lexer));
}
lexer->state = DEFAULT;
return (lexer_lex(alst, lexer));
}