diff --git a/srcs/parsing/valid_syntax/rules_command.c b/srcs/parsing/valid_syntax/rules_command.c index b572e73..d001845 100644 --- a/srcs/parsing/valid_syntax/rules_command.c +++ b/srcs/parsing/valid_syntax/rules_command.c @@ -6,7 +6,7 @@ /* By: lperrey +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2021/10/24 18:52:05 by lperrey #+# #+# */ -/* Updated: 2021/12/17 03:18:49 by lperrey ### ########.fr */ +/* Updated: 2021/12/20 21:11:14 by lperrey ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,66 +18,56 @@ int valid_io_redirect(t_token **token_list); 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); + continue ; + if (!valid_token(token_list, T_WORD)) + return (0); + while (valid_token(token_list, T_WORD) || valid_io_redirect(token_list)) + continue ; + if (!valid_command_separator(*token_list)) + return (0); + return (1); } // 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); + continue ; + if (!valid_token(token_list, T_WORD)) + return (0); + if (!valid_command_separator(*token_list)) + return (0); + return (1); } // 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); + if (!valid_token(token_list, T_WORD)) + return (0); + while (valid_token(token_list, T_WORD) || valid_io_redirect(token_list)) + continue ; + if (!valid_command_separator(*token_list)) + return (0); + return (1); } // 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); + return (0); + if (!valid_command_separator(*token_list)) + return (0); + return (1); } // 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); + continue ; + if (valid_command_separator(*token_list)) + return (0); + return (1); }