Files
42_INT_07_minishell/srcs/parsing/parsing.c
LuckyLaszlo ab2aa509df signals and termios WIP
+ shell script placeholder
+ generics functions
+ valgrind add_history() supp
+ misc
2021-10-30 16:39:24 +02:00

102 lines
3.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/24 10:52:40 by lperrey #+# #+# */
/* Updated: 2021/10/30 15:33:27 by lperrey ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
// A quoi bon un arbre binaire ? Je ne vois plus l'utilité.
/* typedef struct s_binary_tree
{
char *content;
struct s_binary_tree *sub;
struct s_binary_tree *sibling;
enum e_token_id id;
} t_binary_tree; */
t_cmd **parsing(t_token *token_list)
{
t_cmd **cmd_arr;
size_t cmd_nbr;
(void)cmd_arr;
(void)cmd_nbr;
/* t_binary_tree *syntax_tree;
syntax_tree = ft_calloc(1, sizeof *syntax_tree);
if (!syntax_tree)
return (0); //WIP ERROR */
if (!valid_syntax(token_list))
return (NULL);
// Pipes count (determine cmd_nbr)
// Struct CMD alloc/fill
// 2.9.1 - 2) Expansion
// 2.9.1 - 3) Redirection
//return (cmd_arr);
return ((t_cmd **)1); //temp test
}
/* -------------------------------------------------------
The grammar symbols
------------------------------------------------------- */
/*
%token WORD
%token LESS // '<'
%token GREAT // '>'
%token DLESS // '<<'
%token DGREAT // '>>'
%token PIPE // '|'
*/
/* -------------------------------------------------------
The Simplified Grammar
------------------------------------------------------- */
/*
%start program
%%
pipeline : command
| pipeline '|' command
;
command : cmd_prefix cmd_name cmd_suffix
| cmd_prefix cmd_name
| cmd_name cmd_suffix
| cmd_name
;
cmd_name : WORD // Apply rule 7a
;
cmd_prefix : io_redirect
| cmd_prefix io_redirect
;
cmd_suffix : io_redirect
| cmd_suffix io_redirect
| WORD
| cmd_suffix WORD
;
io_redirect : io_file
| io_here
;
io_file : '<' filename
| '>' filename
| DGREAT filename
;
filename : WORD // Apply rule 2
;
io_here : DLESS here_end
;
here_end : WORD // Apply rule 3
;
*/