mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
cmdgroup parsing: handle parsing a single cmdlist (badly)
This commit is contained in:
parent
9707316085
commit
d8dd1613c8
8 changed files with 157 additions and 29 deletions
|
|
@ -6,20 +6,35 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/11 15:18:02 by khais #+# #+# */
|
||||
/* Updated: 2025/03/11 15:18:59 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/11 18:14:24 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "cmdgroup.h"
|
||||
#include <stdlib.h>
|
||||
#include "cmdgroup_item.h"
|
||||
#include "cmdgroup_item_type.h"
|
||||
#include "libft.h"
|
||||
|
||||
t_cmdgroup *cmdgroup_from_wordlist(t_wordlist *words)
|
||||
{
|
||||
(void)words;
|
||||
return (NULL);
|
||||
t_cmdgroup *cmd;
|
||||
|
||||
if (words == NULL)
|
||||
return (NULL);
|
||||
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);
|
||||
}
|
||||
|
||||
void cmdgroup_destroy(t_cmdgroup *cmd)
|
||||
void cmdgroup_destroy(t_cmdgroup *cmd)
|
||||
{
|
||||
(void)cmd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/11 15:11:57 by khais #+# #+# */
|
||||
/* Updated: 2025/03/11 15:17:22 by khais ### ########.fr */
|
||||
/* Updated: 2025/03/11 18:14:33 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,8 +15,18 @@
|
|||
|
||||
# include "../wordlist/wordlist.h"
|
||||
|
||||
struct s_cmdgroup_item;
|
||||
|
||||
typedef struct s_cmdgroup
|
||||
{
|
||||
/*
|
||||
** Number of items in this cmdgroup
|
||||
*/
|
||||
int item_num;
|
||||
/*
|
||||
** array of items in this cmdgroup
|
||||
*/
|
||||
struct s_cmdgroup_item *items;
|
||||
} t_cmdgroup;
|
||||
|
||||
t_cmdgroup *cmdgroup_from_wordlist(t_wordlist *words);
|
||||
|
|
|
|||
30
src/parser/cmdgroup/cmdgroup_item.h
Normal file
30
src/parser/cmdgroup/cmdgroup_item.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* cmdgroup_item.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/11 15:43:15 by khais #+# #+# */
|
||||
/* Updated: 2025/03/11 18:10:24 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CMDGROUP_ITEM_H
|
||||
# define CMDGROUP_ITEM_H
|
||||
|
||||
# include "cmdgroup_item_type.h"
|
||||
# include "../command_list/command_list.h"
|
||||
# include "cmdgroup.h"
|
||||
|
||||
typedef struct s_cmdgroup_item
|
||||
{
|
||||
enum e_cmdgroup_item_type type;
|
||||
union u_cmdgroup_item_inner
|
||||
{
|
||||
t_cmdgroup *cmdgroup;
|
||||
struct s_cmdlist *cmdlist;
|
||||
} inner;
|
||||
} t_cmdgroup_item;
|
||||
|
||||
#endif // CMDGROUP_ITEM_H
|
||||
23
src/parser/cmdgroup/cmdgroup_item_type.h
Normal file
23
src/parser/cmdgroup/cmdgroup_item_type.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* cmdgroup_item_type.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/11 15:45:33 by khais #+# #+# */
|
||||
/* Updated: 2025/03/11 15:46:25 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CMDGROUP_ITEM_TYPE_H
|
||||
# define CMDGROUP_ITEM_TYPE_H
|
||||
|
||||
typedef enum e_cmdgroup_item_type
|
||||
{
|
||||
TYPE_INVALID = 0,
|
||||
TYPE_GROUP,
|
||||
TYPE_LIST,
|
||||
} t_cmdgroup_item_type;
|
||||
|
||||
#endif // CMDGROUP_ITEM_TYPE_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue