minishell/src/lexer/lexer_parse_input.c
2025-02-26 16:17:07 +01:00

45 lines
1.7 KiB
C

/* ************************************************************************** */
/* */
/* :::::::: */
/* lexer_parse_input.c :+: :+: */
/* +:+ */
/* By: qmennen <qmennen@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2025/02/05 19:09:20 by qmennen #+# #+# */
/* Updated: 2025/02/26 16:13:54 by whaffman ######## odam.nl */
/* */
/* ************************************************************************** */
#include "minishell.h"
//TODO: Check if unicode support is viable
/**
* @brief Parses the input from the lexer and returns a list of tokens.
*
* This function continuously retrieves the next token from the lexer and adds
* it to a linked list until an end-of-file (EOF) or error token is encountered.
* The list of tokens is then returned.
*
* @param lexer A pointer to the lexer structure containing
* the input to be parsed.
* @return A linked list of tokens parsed from the input.
*/
t_list *ft_parse_input(t_minishell *msh)
{
t_list *list;
t_token *token;
t_lexer *lexer;
lexer = msh->lexer;
list = NULL;
while (TRUE)
{
token = ft_token_next(msh, lexer);
if (token->type == T_EOF || token->type == T_ERROR)
break ;
ft_lstadd_back(&list, ft_lstnew_safe(msh, token));
}
ft_token_free(msh, token);
return (list);
}