cmdgroup parsing: start implementing the new architecture

This commit is contained in:
Khaïs COLIN 2025-03-18 11:48:03 +01:00
parent d6bb24df54
commit f9aa614ef2
Signed by: logistic-bot
SSH key fingerprint: SHA256:RlpiqKeXpcPFZZ4y9Ou4xi2M8OhRJovIwDlbCaMsuAo
4 changed files with 18 additions and 30 deletions

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/11 15:18:02 by khais #+# #+# */
/* Updated: 2025/03/11 18:14:24 by khais ### ########.fr */
/* Updated: 2025/03/18 11:48:33 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,12 +25,6 @@ t_cmdgroup *cmdgroup_from_wordlist(t_wordlist *words)
cmd = ft_calloc(1, sizeof(t_cmdgroup));
if (cmd == NULL)
return (NULL);
cmd->item_num = 1;
cmd->items = ft_calloc(1, sizeof(t_cmdgroup_item));
if (cmd->items == NULL)
return (free(cmd), NULL);
cmd->items[0].type = TYPE_LIST;
cmd->items[0].inner.cmdlist = cmdlist_from_wordlist(words);
return (cmd);
}

View file

@ -6,7 +6,7 @@
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/11 15:11:57 by khais #+# #+# */
/* Updated: 2025/03/11 18:14:33 by khais ### ########.fr */
/* Updated: 2025/03/18 12:07:29 by khais ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,19 +14,23 @@
# define CMDGROUP_H
# include "../wordlist/wordlist.h"
# include "../command_list/command_list.h"
struct s_cmdgroup_item;
/*
** A grouping of commands, surrounded by parentheses.
**
** A top-level cmdgroup is modeled as having an implicit set of parentheses.
*/
typedef struct s_cmdgroup
{
/*
** Number of items in this cmdgroup
** list of the commands inside this group
*/
int item_num;
struct s_cmdlist item;
/*
** array of items in this cmdgroup
** redirections to apply to the whole group
*/
struct s_cmdgroup_item *items;
struct s_redirection_list *redirections;
} t_cmdgroup;
t_cmdgroup *cmdgroup_from_wordlist(t_wordlist *words);