parse-cmd: Slow start. Ideas starting to coalesce.

This commit is contained in:
Jerome 2025-04-06 21:52:33 +02:00
parent 9acee63d22
commit 90d213bf98

View file

@ -13,9 +13,11 @@
#include "cmd_parsing.h" #include "cmd_parsing.h"
/* /*
** NOTE: This file will temporarily include way more fucntions than allowed. ** NOTE: This file will temporarily include way more functions than allowed.
*/
/*
** Maybe include desctruction of builder contents here.
*/ */
void parse_error(t_minishell *app, t_worddesc *token) void parse_error(t_minishell *app, t_worddesc *token)
{ {
ft_dprintf(STDERR_FILENO, "minishell: syntax error near unexpected " ft_dprintf(STDERR_FILENO, "minishell: syntax error near unexpected "
@ -31,7 +33,7 @@ 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_redirect *minishell_redir_parse(t_minishell *app, t_cmd_builder *builder)
{ {
} }
@ -55,8 +57,23 @@ t_cmd *minishell_pipeline_parse(t_minishell *app, t_cmd_builder *builder)
{ {
} }
/*
** Parse list of commands or pipeline.
*/
t_cmd *minishell_cmds_parse(t_minishell *app, t_cmd_builder *builder) t_cmd *minishell_cmds_parse(t_minishell *app, t_cmd_builder *builder)
{ {
t_cmd *subtree;
t_cmd *opt;
subtree = minishell_pipeline_parse(app, builder);
if (!subtree)
return (NULL); //ft_errno?
ft_errno(FT_ESUCCESS);
opt = minishell_opt_cmds_parse(app, builder);
if (!opt && ft_errno_get() != FT_ESUCCESS)
return (NULL);
if ()
return (subtree);
} }
/* /*
@ -73,7 +90,7 @@ t_cmd *minishell_parse(t_minishell *app, char *command_line)
return (NULL); return (NULL);
root_cmd = minishell_cmds_parse(app, &builder); root_cmd = minishell_cmds_parse(app, &builder);
if (!root_cmd || builder.tokens) if (!root_cmd || builder.tokens)
{ {
parse_error(app, builder.tokens->word); parse_error(app, builder.tokens->word);
return (NULL); return (NULL);
} }