42-archive/42sh/src/lexer/lexer_number.c
ariard@student.42.fr 8d23821d69 after mege
2017-02-20 21:05:12 +01:00

39 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lexer_number.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 12:06:45 by jhalford #+# #+# */
/* Updated: 2017/02/20 20:53:20 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "lexer.h"
int lexer_number(t_list **alst, t_lexer *lexer)
{
t_token *token;
t_lexstate state;
token = (*alst)->content;
if ((state = get_state_global(lexer)))
{
lexer->state = state;
return (lexer_lex(alst, lexer));
}
else if ((state = get_state_redir(lexer)))
{
lexer->state = state;
return (lexer_lex(alst, lexer));
}
else if (ft_isdigit(lexer->str[lexer->pos]))
{
token_append(token, lexer, 0, 0);
lexer->pos++;
return (lexer_number(alst, lexer));
}
lexer->state = DEFAULT;
return (lexer_lex(alst, lexer));
}