patate douce
This commit is contained in:
45
srcs/check_syntax_utils.c
Normal file
45
srcs/check_syntax_utils.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* check_syntax_utils.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tomoron <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/04/24 14:54:53 by tomoron #+# #+# */
|
||||
/* Updated: 2024/04/24 14:55:56 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void print_syntax_error_bonus(t_cmd *cmd)
|
||||
{
|
||||
if (cmd->cmd_type == CMD || cmd->cmd_type == PAREN)
|
||||
return ;
|
||||
ft_printf_fd(2, "minishell : syntax error near unexpected token `");
|
||||
if (cmd->cmd_type == AND)
|
||||
ft_printf_fd(2, "&&");
|
||||
if (cmd->cmd_type == OR)
|
||||
ft_printf_fd(2, "||");
|
||||
if (cmd->cmd_type == PIPE)
|
||||
ft_printf_fd(2, "|");
|
||||
if (cmd->cmd_type == ERR)
|
||||
ft_printf_fd(2, "&");
|
||||
ft_printf_fd(2, "'\n");
|
||||
}
|
||||
|
||||
int check_tokens_syntax(t_cmd *cmd, t_cmd *last, t_env *env)
|
||||
{
|
||||
t_token *token;
|
||||
|
||||
if (last && is_cmd_type(last))
|
||||
{
|
||||
ft_putstr_fd("minishell : syntax error\n", 2);
|
||||
return (0);
|
||||
}
|
||||
token = parse_cmds_to_token(cmd, env);
|
||||
if (!token)
|
||||
return (0);
|
||||
free_token(token);
|
||||
return (1);
|
||||
}
|
Reference in New Issue
Block a user