mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-05 23:18:08 +01:00
parsing: refactor group_or_simple_parse into group_cmd_parse.c
This commit is contained in:
parent
a5103fa733
commit
73d691c0b4
7 changed files with 24 additions and 24 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/31 10:28:28 by jguelen #+# #+# */
|
||||
/* Updated: 2025/04/16 13:02:53 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/16 13:07:33 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,9 +16,7 @@
|
|||
#include "worddesc/worddesc.h"
|
||||
#include "wordlist/wordlist.h"
|
||||
#include <unistd.h>
|
||||
#include "simple_cmd/simple_cmd_parse.h"
|
||||
#include "cmd/cmd_destroy.h"
|
||||
#include "group_cmd/group_cmd_parse.h"
|
||||
#include "pipeline/pipeline_parse.h"
|
||||
#include "cmd/opt_cmds_parse.h"
|
||||
|
||||
|
|
@ -29,17 +27,6 @@ void parse_error(t_minishell *app, t_worddesc *token)
|
|||
app->last_return_value = 2;
|
||||
}
|
||||
|
||||
t_cmd *minishell_group_or_simple_parse(t_minishell *app, t_wordlist **tokens)
|
||||
{
|
||||
if ((*tokens)->word->token_type == OPEN_PARENTH_TOKEN)
|
||||
{
|
||||
worddesc_destroy(wordlist_pop(tokens));
|
||||
return (minishell_group_cmd_parse(app, tokens));
|
||||
}
|
||||
else
|
||||
return (minishell_simple_cmd_parse(app, tokens));
|
||||
}
|
||||
|
||||
/*
|
||||
** Parse list of commands or pipeline.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/15 10:14:13 by khais #+# #+# */
|
||||
/* Updated: 2025/04/16 13:02:00 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/16 13:06:06 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -22,7 +22,5 @@ t_redirect *t_redirect_add_back(t_redirect **init, t_redirect *back);
|
|||
t_cmd *minishell_parse(t_minishell *app, char *command_line);
|
||||
|
||||
t_cmd *minishell_cmds_parse(t_minishell *app, t_wordlist **tokens);
|
||||
t_cmd *minishell_group_or_simple_parse(t_minishell *app,
|
||||
t_wordlist **tokens);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/15 10:46:28 by khais #+# #+# */
|
||||
/* Updated: 2025/04/15 14:08:40 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/16 13:06:40 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
#include "../cmd/cmd_destroy.h"
|
||||
#include "../cmd/cmd.h"
|
||||
#include "../redirect/redirect_parse.h"
|
||||
#include "../simple_cmd/simple_cmd_parse.h"
|
||||
|
||||
t_cmd *minishell_group_cmd_parse(t_minishell *app, t_wordlist **tokens)
|
||||
{
|
||||
|
|
@ -41,3 +42,14 @@ t_cmd *minishell_group_cmd_parse(t_minishell *app, t_wordlist **tokens)
|
|||
return (cmd_destroy(group), NULL);
|
||||
return (group);
|
||||
}
|
||||
|
||||
t_cmd *minishell_group_or_simple_parse(t_minishell *app, t_wordlist **tokens)
|
||||
{
|
||||
if ((*tokens)->word->token_type == OPEN_PARENTH_TOKEN)
|
||||
{
|
||||
worddesc_destroy(wordlist_pop(tokens));
|
||||
return (minishell_group_cmd_parse(app, tokens));
|
||||
}
|
||||
else
|
||||
return (minishell_simple_cmd_parse(app, tokens));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/15 10:45:49 by khais #+# #+# */
|
||||
/* Updated: 2025/04/15 14:06:54 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/16 13:06:53 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,5 +16,7 @@
|
|||
# include "../../minishell.h"
|
||||
|
||||
t_cmd *minishell_group_cmd_parse(t_minishell *app, t_wordlist **tokens);
|
||||
t_cmd *minishell_group_or_simple_parse(t_minishell *app,
|
||||
t_wordlist **tokens);
|
||||
|
||||
#endif // GROUP_CMD_PARSE_H
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/15 10:43:04 by khais #+# #+# */
|
||||
/* Updated: 2025/04/15 14:15:18 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/16 13:08:08 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "optional_pipeline_parse.h"
|
||||
#include "../../ft_errno.h"
|
||||
#include "../cmd_parsing.h"
|
||||
#include "../group_cmd/group_cmd_parse.h"
|
||||
|
||||
t_cmd *minishell_optional_pipeline_parse(t_minishell *app,
|
||||
t_wordlist **tokens)
|
||||
|
|
|
|||
|
|
@ -6,15 +6,16 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/15 11:35:08 by khais #+# #+# */
|
||||
/* Updated: 2025/04/15 14:09:28 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/16 13:07:51 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "pipeline_parse.h"
|
||||
#include "optional_pipeline_parse.h"
|
||||
#include "../cmd_parsing.h"
|
||||
#include "../cmd/cmd_destroy.h"
|
||||
#include "../connec_cmd/connec_reorient_subtree.h"
|
||||
#include "../group_cmd/group_cmd_parse.h"
|
||||
#include "../../ft_errno.h"
|
||||
|
||||
t_cmd *minishell_pipeline_parse(t_minishell *app, t_wordlist **tokens)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/20 10:26:05 by jguelen #+# #+# */
|
||||
/* Updated: 2025/04/04 17:05:32 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/16 13:06:40 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue