parse-cmd: A very basic skeleton of functions to come

This commit is contained in:
Jérôme Guélen 2025-04-04 18:26:10 +02:00 committed by Jerome
parent f490cc22f5
commit 5f95751b36
3 changed files with 105 additions and 6 deletions

79
src/parser/cmd_parsing.c Normal file
View file

@ -0,0 +1,79 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* cmd_parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jguelen <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/31 10:28:28 by jguelen #+# #+# */
/* Updated: 2025/04/04 18:21:17 by jguelen ### ########.fr */
/* */
/* ************************************************************************** */
#include "cmd_parsing.h"
/*
** NOTE: Tjis file will temporarily include way more fucntions than allowed.
*/
void parse_error(t_minishell *app, t_worddesc *token)
{
ft_dprintf(STDERR_FILENO, "minishell: syntax error near unexpected "
"token `%s'", token->word);
app->last_return_value = 2;
}
t_connector which_connector_type(t_worddesc *token)
{
}
t_cmd *minishell_simple_lst_parse(t_minishell *app, t_cmd_builder *builder)
{
}
t_cmd *minishell_redir_parse(t_minishell *app, t_cmd_builder *builder)
{
}
t_cmd *minishell_simple_parse(t_minishell *app, t_cmd_builder *builder)
{
}
t_cmd *minishell_opt_pipeline_parse(t_minishell *app, t_cmd_builder *builder)
{
}
t_cmd *minishell_group_or_smp_parse(t_minishell *app, t_cmd_builder *builder)
{
}
t_cmd *minishell_opt_cmds_parse(t_minishell *app, t_cmd_builder *builder)
{
}
t_cmd *minishell_pipeline_parse(t_minishell *app, t_cmd_builder *builder)
{
}
t_cmd *minishell_cmds_parse(t_minishell *app, t_cmd_builder *builder)
{
}
/*
** TODO Recheck error cases to see if allocation error occurred or something
** else and if this is necessary.
*/
t_cmd *minishell_parse(t_minishell *app, char *command_line)
{
t_cmd_builder builder;
t_cmd *root_cmd;
builder.tokens = minishell_wordsplit(command_line);
root_cmd = minishell_cmds_parse(app, &builder);
if (!root_cmd || builder.tokens)
{
parse_error(app, builder.tokens->word);
return (NULL);
}
return (root_cmd);
}