perdu entre les 2 libs de lst :( to-do tomorroz

This commit is contained in:
AntoHesse 2017-03-03 02:00:15 +01:00
parent 7f82901608
commit b9d8b949be
9 changed files with 40 additions and 36 deletions

View file

@ -236,6 +236,7 @@ parser/add_sep.c\
parser/add_case.c\ parser/add_case.c\
parser/add_func.c\ parser/add_func.c\
parser/add_redir.c\ parser/add_redir.c\
parser/add_pipe.c\
parser/aggregate_sym.c\ parser/aggregate_sym.c\
parser/build_tree.c\ parser/build_tree.c\
parser/error_syntax.c\ parser/error_syntax.c\

View file

@ -124,6 +124,7 @@ int add_subshell_sep(t_btree **ast, t_list **lst);
int add_func_cmd(t_btree **ast, t_list **lst); int add_func_cmd(t_btree **ast, t_list **lst);
int add_func_sep(t_btree **ast, t_list **lst); int add_func_sep(t_btree **ast, t_list **lst);
int add_one_func(t_btree **ast, t_list **lst); int add_one_func(t_btree **ast, t_list **lst);
int add_pipe(t_btree **ast, t_list **lst);
int isloop(t_btree **ast, t_list **lst); int isloop(t_btree **ast, t_list **lst);
int iscase(t_btree **ast, t_list **lst); int iscase(t_btree **ast, t_list **lst);
int iscondition(t_btree **ast, t_list **lst); int iscondition(t_btree **ast, t_list **lst);

@ -1 +1 @@
Subproject commit 8f6e64fa9b4ac1dd3e3d5200fb93471ddfeedd40 Subproject commit bfc8ca207ab4d39f0140322c0f1d368137304a3c

View file

@ -22,7 +22,8 @@ char **token_to_argv(t_astnode *node)
if (node->type == TK_WORD || node->type == TK_ASSIGNEMENT_WORD) if (node->type == TK_WORD || node->type == TK_ASSIGNEMENT_WORD)
{ {
ld = node->data.cmd.token; ld = NULL;
// ld = node->data.cmd.token;
my_tab = NULL; my_tab = NULL;
while (ld) while (ld)
{ {

View file

@ -1,29 +1,6 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* ::: :::::::: */ /* ::: :::::::: */
" ============================================================================
" Netrw Directory Listing (netrw v140)
" /Users/antoineriard/42sh
" Sorted by name
" Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec
" ============================================================================
../
.git/
includes/
libft/
pdf/
sample/
src/
.gitignore
.gitmodules
.tags
.valgrind.supp
Makefile
STDBUG
donovan_segaults_06-02
update_makefile.sh*
.swp
/* add_cmd.c :+: :+: :+: */ /* add_cmd.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
@ -39,6 +16,7 @@ int add_cmd(t_btree **ast, t_list **lst)
{ {
t_token *token; t_token *token;
t_astnode *node; t_astnode *node;
t_cmd *cmd;
char **my_tab; char **my_tab;
if ((token = (*lst)->content)->type == TK_IN || token->type == TK_PAREN_OPEN) if ((token = (*lst)->content)->type == TK_IN || token->type == TK_PAREN_OPEN)
@ -76,11 +54,17 @@ int add_cmd(t_btree **ast, t_list **lst)
node->type = JOB; node->type = JOB;
if (token->type == TK_WORD || token->type == TK_ASSIGNEMENT_WORD) if (token->type == TK_WORD || token->type == TK_ASSIGNEMENT_WORD)
{ {
DG("add data"); DG("add data");
return ;
if (!node->data.cmds)
node->data.cmds = ft_lstnew(&cmd, sizeof(t_ld));
ft_lstlast(node->data.cmds)->content;
my_tab = ft_sstradd(my_tab, token->data); my_tab = ft_sstradd(my_tab, token->data);
my_tab = ft_sstradd(my_tab, (char *)token->esc); my_tab = ft_sstradd(my_tab, (char *)token->esc);
my_tab = ft_sstradd(my_tab, (char *)token->esc2); my_tab = ft_sstradd(my_tab, (char *)token->esc2);
ft_ld_pushback(&node->data.cmd.token, my_tab);
ft_ld_pushback(&cmd->token, my_tab);
} }
return (0); return (0);
} }

View file

@ -0,0 +1,12 @@
#include "parser.h"
int add_pipe(t_btree **ast, t_list **lst)
{
t_astnode *node;
t_cmd *cmd;
(void)lst;
node = (*ast)->item;
ft_lsteadd(&node->data.cmds, ft_lstnew(&cmd, sizeof(cmd)));
return (0);
}

View file

@ -57,17 +57,19 @@ int add_redir_word(t_btree **ast, t_list **lst)
t_astnode *node; t_astnode *node;
t_token *token; t_token *token;
t_redir *redir; t_redir *redir;
t_cmd *cmd;
token = (*lst)->content; token = (*lst)->content;
node = (*ast)->item; node = (*ast)->item;
if (node->data.cmd.redir) cmd = (ft_lstlast(node->data.cmds))->content;
if (cmd->redir)
{ {
DG("add file"); DG("add file");
redir = (ft_lstlast(node->data.cmd.redir))->content; redir = (ft_lstlast(cmd->redir))->content;
if (redir->type == TK_DLESS) if (redir->type == TK_DLESS)
redir->word.word = NULL; redir->word.word = NULL;
else if (ft_stris((char *)token->data, &ft_isdigit)) // else if (ft_stris((char *)token->data, &ft_isdigit))
redir->word.fd = ft_atoi(token->data); // redir->word.fd = ft_atoi(token->data);
else else
redir->word.word = token->data; redir->word.word = token->data;
} }
@ -79,6 +81,7 @@ int add_redir_type(t_btree **ast, t_list **lst)
t_astnode *node; t_astnode *node;
t_token *token; t_token *token;
t_redir *redir; t_redir *redir;
t_cmd *cmd;
DG("add redir"); DG("add redir");
if (!*ast) if (!*ast)
@ -88,6 +91,9 @@ int add_redir_type(t_btree **ast, t_list **lst)
node->type = REDIR; node->type = REDIR;
redir = ft_memalloc(sizeof(redir)); redir = ft_memalloc(sizeof(redir));
redir->type = token->type; redir->type = token->type;
ft_lsteadd(&node->data.cmd.redir, ft_lstnew(redir, sizeof(redir))); if (!node->data.cmds)
node->data.cmds = ft_lstnew(&cmd, sizeof(cmd));
cmd = (node->data.cmds)->content;
ft_lsteadd(&cmd->redir, ft_lstnew(redir, sizeof(redir)));
return (0); return (0);
} }

View file

@ -15,7 +15,7 @@
t_treematch g_treematch[] = t_treematch g_treematch[] =
{ {
{TK_WORD, &add_cmd}, {TK_WORD, &add_cmd},
{TK_PIPE, &add_sep}, {TK_PIPE, &add_pipe},
{TK_SEMI, &add_sep}, {TK_SEMI, &add_sep},
{TK_GREAT, &add_cmd}, {TK_GREAT, &add_cmd},
{TK_LESS, &add_cmd}, {TK_LESS, &add_cmd},

View file

@ -27,7 +27,6 @@ int gen_node(t_btree **ast)
{ {
*ast = btree_create_node(&item, sizeof(item)); *ast = btree_create_node(&item, sizeof(item));
ft_bzero((void *)&((t_astnode *)(*ast)->item)->data, sizeof(t_astdata)); ft_bzero((void *)&((t_astnode *)(*ast)->item)->data, sizeof(t_astdata));
// ((t_astnode *)(*ast)->item)->data.cmd.token = NULL;
((t_astnode *)(*ast)->item)->nest = 0; ((t_astnode *)(*ast)->item)->nest = 0;
((t_astnode *)(*ast)->item)->full = 0; ((t_astnode *)(*ast)->item)->full = 0;
((t_astnode *)(*ast)->item)->type = 0; ((t_astnode *)(*ast)->item)->type = 0;