From 90d213bf9800b3aa7083a338475a86df18cc28b8 Mon Sep 17 00:00:00 2001 From: Jerome Date: Sun, 6 Apr 2025 21:52:33 +0200 Subject: [PATCH] parse-cmd: Slow start. Ideas starting to coalesce. --- src/parser/cmd_parsing.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/parser/cmd_parsing.c b/src/parser/cmd_parsing.c index 2df1872..2742b03 100644 --- a/src/parser/cmd_parsing.c +++ b/src/parser/cmd_parsing.c @@ -13,9 +13,11 @@ #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) { 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 *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); root_cmd = minishell_cmds_parse(app, &builder); if (!root_cmd || builder.tokens) - { + { parse_error(app, builder.tokens->word); return (NULL); }