mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
cmdgroup parsing: parse empty wordlist
This commit is contained in:
parent
8f919b33df
commit
bc5be67bf6
5 changed files with 98 additions and 0 deletions
1
Makefile
1
Makefile
|
|
@ -30,6 +30,7 @@ srcs = \
|
||||||
src/executing/here_doc/strip_newline.c \
|
src/executing/here_doc/strip_newline.c \
|
||||||
src/ft_errno.c \
|
src/ft_errno.c \
|
||||||
src/get_command.c \
|
src/get_command.c \
|
||||||
|
src/parser/cmdgroup/cmdgroup.c \
|
||||||
src/parser/command_list/command_list_builder.c \
|
src/parser/command_list/command_list_builder.c \
|
||||||
src/parser/command_list/command_list.c \
|
src/parser/command_list/command_list.c \
|
||||||
src/parser/command_list/operator.c \
|
src/parser/command_list/operator.c \
|
||||||
|
|
|
||||||
25
src/parser/cmdgroup/cmdgroup.c
Normal file
25
src/parser/cmdgroup/cmdgroup.c
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* cmdgroup.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/03/11 15:18:02 by khais #+# #+# */
|
||||||
|
/* Updated: 2025/03/11 15:18:59 by khais ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "cmdgroup.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
t_cmdgroup *cmdgroup_from_wordlist(t_wordlist *words)
|
||||||
|
{
|
||||||
|
(void)words;
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmdgroup_destroy(t_cmdgroup *cmd)
|
||||||
|
{
|
||||||
|
(void)cmd;
|
||||||
|
}
|
||||||
25
src/parser/cmdgroup/cmdgroup.h
Normal file
25
src/parser/cmdgroup/cmdgroup.h
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* cmdgroup.h :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/03/11 15:11:57 by khais #+# #+# */
|
||||||
|
/* Updated: 2025/03/11 15:17:22 by khais ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef CMDGROUP_H
|
||||||
|
# define CMDGROUP_H
|
||||||
|
|
||||||
|
# include "../wordlist/wordlist.h"
|
||||||
|
|
||||||
|
typedef struct s_cmdgroup
|
||||||
|
{
|
||||||
|
} t_cmdgroup;
|
||||||
|
|
||||||
|
t_cmdgroup *cmdgroup_from_wordlist(t_wordlist *words);
|
||||||
|
void cmdgroup_destroy(t_cmdgroup *cmd);
|
||||||
|
|
||||||
|
#endif // CMDGROUP_H
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
# file are prefixed with test_
|
# file are prefixed with test_
|
||||||
rawtests = \
|
rawtests = \
|
||||||
expansion \
|
expansion \
|
||||||
|
test_cmdgroup_parsing \
|
||||||
test_here_doc \
|
test_here_doc \
|
||||||
test_wordlist_idx \
|
test_wordlist_idx \
|
||||||
test_redirection_parsing \
|
test_redirection_parsing \
|
||||||
|
|
|
||||||
46
tests/test_cmdgroup_parsing.c
Normal file
46
tests/test_cmdgroup_parsing.c
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* test_cmdgroup_parsing.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/03/11 15:07:23 by khais #+# #+# */
|
||||||
|
/* Updated: 2025/03/11 15:20:17 by khais ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "testutil.h"
|
||||||
|
#include <assert.h>
|
||||||
|
#include "libft.h"
|
||||||
|
#include "../src/parser/cmdgroup/cmdgroup.h"
|
||||||
|
#include "../src/parser/wordsplit/wordsplit.h"
|
||||||
|
|
||||||
|
static t_cmdgroup *parse_cmdgroup(char *input)
|
||||||
|
{
|
||||||
|
ft_dprintf(STDERR_FILENO, "Now checking command group with input [%s]\n", input);
|
||||||
|
t_wordlist *words = minishell_wordsplit(input);
|
||||||
|
t_cmdgroup *cmd = cmdgroup_from_wordlist(words);
|
||||||
|
wordlist_destroy(words);
|
||||||
|
return (cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_cmdgroup_parsing_empty(void)
|
||||||
|
{
|
||||||
|
t_cmdgroup *cmd;
|
||||||
|
|
||||||
|
// arange
|
||||||
|
ft_dprintf(STDERR_FILENO, "==> %s <==\n", __FUNCTION__);
|
||||||
|
cmd = parse_cmdgroup("");
|
||||||
|
// assert
|
||||||
|
assert(NULL == cmd);
|
||||||
|
// cleanup
|
||||||
|
cmdgroup_destroy(cmd);
|
||||||
|
do_leak_check();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
test_cmdgroup_parsing_empty();
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue