a jour avec la branche master
This commit is contained in:
2
Makefile
2
Makefile
@@ -34,7 +34,7 @@ SRCS = main.c \
|
|||||||
signals.c error_wrappers.c last_exit_status.c \
|
signals.c error_wrappers.c last_exit_status.c \
|
||||||
lexing.c fill_token.c check_operators.c \
|
lexing.c fill_token.c check_operators.c \
|
||||||
parsing.c create_pipeline.c \
|
parsing.c create_pipeline.c \
|
||||||
valid_syntax.c valid_pipeline.c valid_command.c valid_io_redirect.c \
|
valid_syntax.c valid_pipeline.c valid_command.c rules_command.c valid_io_redirect.c \
|
||||||
expansions.c expand_token.c rejoin_after_expand.c new_token_for_each_field.c \
|
expansions.c expand_token.c rejoin_after_expand.c new_token_for_each_field.c \
|
||||||
redirections.c here_doc.c \
|
redirections.c here_doc.c \
|
||||||
exec_cmd_line.c pipeline.c \
|
exec_cmd_line.c pipeline.c \
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/11/16 01:57:38 by lperrey #+# #+# */
|
/* Created: 2021/11/16 01:57:38 by lperrey #+# #+# */
|
||||||
/* Updated: 2021/12/11 05:24:07 by lperrey ### ########.fr */
|
/* Updated: 2021/12/16 15:55:36 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ static int pipeline_find_access(t_cmd *pipeline[], char *path[])
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (pipeline[i])
|
while (pipeline[i])
|
||||||
{
|
{
|
||||||
if (!pipeline[i]->error)
|
if (!pipeline[i]->error && pipeline[i]->argv[0])
|
||||||
{
|
{
|
||||||
if (!cmd_find_access(pipeline[i], path))
|
if (!cmd_find_access(pipeline[i], path))
|
||||||
return (0);
|
return (0);
|
||||||
@@ -91,7 +91,7 @@ static pid_t pipeline_exec(t_cmd *pipeline[], t_all *c)
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (pipeline[i])
|
while (pipeline[i])
|
||||||
{
|
{
|
||||||
if (!pipeline[i]->error)
|
if (!pipeline[i]->error && pipeline[i]->argv[0])
|
||||||
{
|
{
|
||||||
ret = cmd_exec_in_subshell(pipeline[i], c);
|
ret = cmd_exec_in_subshell(pipeline[i], c);
|
||||||
if (ret != EXIT_SUCCESS)
|
if (ret != EXIT_SUCCESS)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/24 10:52:40 by lperrey #+# #+# */
|
/* Created: 2021/10/24 10:52:40 by lperrey #+# #+# */
|
||||||
/* Updated: 2021/12/16 14:50:16 by hulamy ### ########.fr */
|
/* Updated: 2021/12/17 17:45:25 by hulamy ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -93,6 +93,7 @@ command : cmd_prefix cmd_name cmd_suffix
|
|||||||
| cmd_prefix cmd_name
|
| cmd_prefix cmd_name
|
||||||
| cmd_name cmd_suffix
|
| cmd_name cmd_suffix
|
||||||
| cmd_name
|
| cmd_name
|
||||||
|
| cmd_prefix
|
||||||
;
|
;
|
||||||
cmd_name : WORD // Apply rule 7a
|
cmd_name : WORD // Apply rule 7a
|
||||||
;
|
;
|
||||||
|
|||||||
83
srcs/parsing/valid_syntax/rules_command.c
Normal file
83
srcs/parsing/valid_syntax/rules_command.c
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* rules_command.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2021/10/24 18:52:05 by lperrey #+# #+# */
|
||||||
|
/* Updated: 2021/12/17 03:18:49 by lperrey ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
int valid_io_redirect(t_token **token_list);
|
||||||
|
|
||||||
|
// cmd_prefix cmd_name cmd_suffix
|
||||||
|
int valid_command_rule1(t_token **token_list)
|
||||||
|
{
|
||||||
|
while (valid_io_redirect(token_list))
|
||||||
|
{
|
||||||
|
if (valid_token(token_list, T_WORD))
|
||||||
|
{
|
||||||
|
while (valid_token(token_list, T_WORD)
|
||||||
|
|| valid_io_redirect(token_list))
|
||||||
|
{
|
||||||
|
if (valid_command_separator(*token_list))
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// cmd_prefix cmd_name
|
||||||
|
int valid_command_rule2(t_token **token_list)
|
||||||
|
{
|
||||||
|
while (valid_io_redirect(token_list))
|
||||||
|
{
|
||||||
|
if (valid_token(token_list, T_WORD))
|
||||||
|
{
|
||||||
|
if (valid_command_separator(*token_list))
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// cmd_name cmd_suffix
|
||||||
|
int valid_command_rule3(t_token **token_list)
|
||||||
|
{
|
||||||
|
if (valid_token(token_list, T_WORD))
|
||||||
|
{
|
||||||
|
while (valid_token(token_list, T_WORD) || valid_io_redirect(token_list))
|
||||||
|
{
|
||||||
|
if (valid_command_separator(*token_list))
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// cmd_name
|
||||||
|
int valid_command_rule4(t_token **token_list)
|
||||||
|
{
|
||||||
|
if (valid_token(token_list, T_WORD))
|
||||||
|
{
|
||||||
|
if (valid_command_separator(*token_list))
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// cmd_prefix
|
||||||
|
int valid_command_rule5(t_token **token_list)
|
||||||
|
{
|
||||||
|
while (valid_io_redirect(token_list))
|
||||||
|
{
|
||||||
|
if (valid_command_separator(*token_list))
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
@@ -6,18 +6,17 @@
|
|||||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/10/24 18:52:05 by lperrey #+# #+# */
|
/* Created: 2021/10/24 18:52:05 by lperrey #+# #+# */
|
||||||
/* Updated: 2021/10/24 19:21:28 by lperrey ### ########.fr */
|
/* Updated: 2021/12/17 03:28:53 by lperrey ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int valid_io_redirect(t_token **token_list);
|
int valid_command_rule1(t_token **token_list);
|
||||||
|
int valid_command_rule2(t_token **token_list);
|
||||||
static int valid_command_rule1(t_token **token_list);
|
int valid_command_rule3(t_token **token_list);
|
||||||
static int valid_command_rule2(t_token **token_list);
|
int valid_command_rule4(t_token **token_list);
|
||||||
static int valid_command_rule3(t_token **token_list);
|
int valid_command_rule5(t_token **token_list);
|
||||||
static int valid_command_rule4(t_token **token_list);
|
|
||||||
|
|
||||||
int valid_command(t_token **token_list)
|
int valid_command(t_token **token_list)
|
||||||
{
|
{
|
||||||
@@ -35,62 +34,8 @@ int valid_command(t_token **token_list)
|
|||||||
*token_list = cmd_start;
|
*token_list = cmd_start;
|
||||||
if (valid_command_rule4(token_list))
|
if (valid_command_rule4(token_list))
|
||||||
return (1);
|
return (1);
|
||||||
return (0);
|
*token_list = cmd_start;
|
||||||
}
|
if (valid_command_rule5(token_list))
|
||||||
|
|
||||||
// cmd_prefix cmd_name cmd_suffix
|
|
||||||
static int valid_command_rule1(t_token **token_list)
|
|
||||||
{
|
|
||||||
while (valid_io_redirect(token_list))
|
|
||||||
{
|
|
||||||
if (valid_token(token_list, T_WORD))
|
|
||||||
{
|
|
||||||
while (valid_token(token_list, T_WORD)
|
|
||||||
|| valid_io_redirect(token_list))
|
|
||||||
{
|
|
||||||
if (valid_command_separator(*token_list))
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// cmd_prefix cmd_name
|
|
||||||
static int valid_command_rule2(t_token **token_list)
|
|
||||||
{
|
|
||||||
while (valid_io_redirect(token_list))
|
|
||||||
{
|
|
||||||
if (valid_token(token_list, T_WORD))
|
|
||||||
{
|
|
||||||
if (valid_command_separator(*token_list))
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// cmd_name cmd_suffix
|
|
||||||
static int valid_command_rule3(t_token **token_list)
|
|
||||||
{
|
|
||||||
if (valid_token(token_list, T_WORD))
|
|
||||||
{
|
|
||||||
while (valid_token(token_list, T_WORD) || valid_io_redirect(token_list))
|
|
||||||
{
|
|
||||||
if (valid_command_separator(*token_list))
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// cmd_name
|
|
||||||
static int valid_command_rule4(t_token **token_list)
|
|
||||||
{
|
|
||||||
if (valid_token(token_list, T_WORD))
|
|
||||||
{
|
|
||||||
if (valid_command_separator(*token_list))
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user