feat: add heredoc token
This commit is contained in:
parent
486a207834
commit
df6b7a41ae
@ -20,6 +20,7 @@ typedef enum e_token_type
|
||||
T_REDIRECT_IN,
|
||||
T_REDIRECT_OUT,
|
||||
T_APPEND_OUT,
|
||||
T_HEREDOC,
|
||||
T_EOF,
|
||||
T_ERROR
|
||||
} t_token_type;
|
||||
|
||||
12
src/main.c
12
src/main.c
@ -10,9 +10,18 @@
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include "minishell.h"
|
||||
#include "utils.h"
|
||||
|
||||
static void token_print(void *param)
|
||||
{
|
||||
t_token *token;
|
||||
|
||||
token = (t_token *)param;
|
||||
printf("token type %i, value %s\n", token->type, token->value);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv, char **envp)
|
||||
{
|
||||
t_minishell *minishell;
|
||||
@ -28,7 +37,8 @@ int main(int argc, char **argv, char **envp)
|
||||
minishell->line = ft_prompt(minishell);
|
||||
minishell->lexer = ft_lexer_new(minishell->line);
|
||||
minishell->tokens = ft_parse_input(minishell->lexer);
|
||||
minishell->commands = parser_get_commands(minishell->tokens);
|
||||
ft_lstiter(minishell->tokens, token_print);
|
||||
// minishell->commands = parser_get_commands(minishell->tokens);
|
||||
simple_builtins(minishell);
|
||||
free_minishell_line(minishell);
|
||||
ft_lstclear(&minishell->commands, free_command_list);
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* parse_token.c :+: :+: :+: */
|
||||
/* token_parse.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: qmennen <qmennen@student.codam.nl> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/05 19:10:17 by qmennen #+# #+# */
|
||||
/* Updated: 2025/02/05 19:11:21 by qmennen ### ########.fr */
|
||||
/* Updated: 2025/02/11 17:38:51 by qmennen ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -21,6 +21,11 @@ t_token *ft_parse_token(t_lexer *lexer)
|
||||
{
|
||||
token = ft_token_new(T_PIPE, "|", lexer->pos);
|
||||
}
|
||||
else if (lexer->current_char == '<' && lexer->input[lexer->pos + 1] == '<')
|
||||
{
|
||||
token = ft_token_new(T_HEREDOC, "<<", lexer->pos);
|
||||
ft_lexer_readchar(lexer);
|
||||
}
|
||||
else if (lexer->current_char == '<')
|
||||
{
|
||||
token = ft_token_new(T_REDIRECT_IN, "<", lexer->pos);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user