grosse mise a la norme des func parser

This commit is contained in:
Antoine Riard 2017-03-11 16:24:18 +01:00
parent 7708a456a9
commit 729cf55cd3
26 changed files with 177 additions and 240 deletions

View file

@ -77,7 +77,7 @@ int pop_stack(t_list **stack, t_sym erase_sym);
int pop_heredoc(t_list **lst);
int error_syntax(t_list **token, t_parser *parser, t_btree **ast);
int error_EOF(t_list **token, t_parser *parser, t_btree **ast);
int error_eof(t_list **token, t_parser *parser, t_btree **ast);
int ft_read_stack(t_sym *stack);
char *read_state(t_sym current);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/03/10 16:29:09 by ariard ### ########.fr */
/* Updated: 2017/03/11 16:10:29 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -33,7 +33,7 @@ int handle_instruction(int fd)
{
if (ret == -1)
return (-1);
return (parser.state == UNDEFINED ? error_EOF(&token,
return (parser.state == UNDEFINED ? error_eof(&token,
&parser, &ast) : 1);
}
if (lexer.state == HEREDOC)
@ -70,10 +70,9 @@ int handle_instruction(int fd)
return (error_syntax(&token, &parser, &ast));
}
}
DG("Before execution:");
btree_print(STDBUG, ast, &ft_putast);
// if (ft_exec(&ast))
// return (1);
if (ft_exec(&ast))
return (1);
instruction_free(&token, &parser, &ast);
ft_add_str_in_history(lexer.str);
return (0);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/10 14:57:45 by ariard #+# #+# */
/* Updated: 2017/03/10 17:35:55 by ariard ### ########.fr */
/* Updated: 2017/03/11 16:23:26 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -39,8 +39,9 @@ int isbang_sep(t_btree **ast, t_list **lst)
if (*ast)
{
node = (*ast)->item;
if ((token->type == TK_SEMI || token->type == TK_AMP || token->type == TK_NEWLINE
|| token->type == TK_AND_IF || token->type == TK_OR_IF) && node->type == TK_BANG
if ((token->type == TK_SEMI || token->type == TK_AMP
|| token->type == TK_NEWLINE || token->type == TK_AND_IF
|| token->type == TK_OR_IF) && node->type == TK_BANG
&& node->nest == 0)
node->full = 1;
if (token->type == TK_PIPE && node->type == TK_BANG && node->full == 0)
@ -58,12 +59,13 @@ int add_bang(t_btree **ast, t_list **lst)
token = (*lst)->content;
node = (*ast)->item;
if ((token->type == TK_CASE || token->type == TK_WHILE
|| token->type == TK_IF || token->type == TK_UNTIL || token->type == TK_FOR
|| token->type == SUBSHELL || token->type == TK_LBRACE)
&& node->type == TK_BANG)
|| token->type == TK_IF || token->type == TK_UNTIL
|| token->type == TK_FOR || token->type == SUBSHELL
|| token->type == TK_LBRACE) && node->type == TK_BANG)
node->nest++;
if ((token->type == TK_DONE || token->type == TK_ESAC || token->type == TK_FI
|| token->type == TK_RBRACE || token->type == TK_PAREN_CLOSE)
if ((token->type == TK_DONE || token->type == TK_ESAC
|| token->type == TK_FI || token->type == TK_RBRACE
|| token->type == TK_PAREN_CLOSE)
&& node->type == TK_BANG && node->nest > 0)
node->nest--;
return (add_cmd(&(*ast)->right, lst));

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/04 20:42:13 by ariard #+# #+# */
/* Updated: 2017/03/10 18:10:47 by ariard ### ########.fr */
/* Updated: 2017/03/11 15:33:30 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,7 +21,7 @@ int iscase(t_btree **ast, t_list **lst)
if (*ast)
{
node = (*ast)->item;
if (node->type == TK_CASE|| node->type == TK_PAREN_OPEN)
if (node->type == TK_CASE || node->type == TK_PAREN_OPEN)
return (1);
}
return (0);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 20:49:15 by ariard #+# #+# */
/* Updated: 2017/03/11 15:06:03 by ariard ### ########.fr */
/* Updated: 2017/03/11 15:34:23 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -75,10 +75,7 @@ int add_cmd(t_btree **ast, t_list **lst)
i = -1;
while (++i < 19)
if (g_distrostree[i].test(ast, lst) == 1)
{
DG("add : %d", i);
return (g_distrostree[i].add(ast, lst));
}
if (!*ast)
gen_node(ast);
else if (no_del_token(ast, lst))

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/10 17:06:16 by ariard #+# #+# */
/* Updated: 2017/03/10 18:10:42 by ariard ### ########.fr */
/* Updated: 2017/03/11 15:36:33 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,8 +25,8 @@ int iscondition(t_btree **ast, t_list **lst)
if ((node->type == TK_NEWLINE || node->type == TK_SEMI
|| node->type == TK_AMP) && iscondition(&(*ast)->right, lst) == 1)
return (1);
if ((node->type == TK_IF || node->type == TK_ELIF || node->type == TK_ELSE)
&& node->full == 0)
if ((node->type == TK_IF || node->type == TK_ELIF
|| node->type == TK_ELSE) && node->full == 0)
return (1);
}
return (0);
@ -63,8 +63,8 @@ int add_condition_cmd(t_btree **ast, t_list **lst)
if (token->type == TK_FI && (node->type == TK_IF || node->type == TK_ELIF
|| node->type == TK_ELSE) && node->nest > 0)
node->nest--;
else if (token->type == TK_FI && (node->type == TK_IF || node->type == TK_ELIF
|| node->type == TK_ELSE))
else if (token->type == TK_FI && (node->type == TK_IF
|| node->type == TK_ELIF || node->type == TK_ELSE))
return ((node->full = 1));
if (token->type == TK_THEN)
return (add_cmd(&(*ast)->right, lst));
@ -75,7 +75,6 @@ int add_condition_cmd(t_btree **ast, t_list **lst)
return (0);
}
int add_condition_sep(t_btree **ast, t_list **lst)
{
if (!(*ast)->right)

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/24 23:43:07 by ariard #+# #+# */
/* Updated: 2017/03/08 03:21:13 by wescande ### ########.fr */
/* Updated: 2017/03/11 15:41:11 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -23,12 +23,12 @@ int isfunc_name(t_btree **ast, t_list **lst)
node = (*ast)->item;
if (node->type == CMD && token->type == TK_PAREN_OPEN)
{
DG("add func name");
node->type = FNAME;
node->data.str = ft_strdup(token->data);
return (1);
}
if (node->type == FNAME && token->type == TK_PAREN_CLOSE && node->nest == 0)
if (node->type == FNAME && token->type == TK_PAREN_CLOSE
&& node->nest == 0)
return (1);
}
return (0);
@ -57,21 +57,22 @@ int add_func_cmd(t_btree **ast, t_list **lst)
t_astnode *node;
t_token *token;
DG("add func cmd");
token = (*lst)->content;
node = (*ast)->item;
if ((token->type == TK_CASE || token->type == TK_WHILE || token->type == TK_IF
|| token->type == TK_UNTIL || token->type == TK_FOR
|| token->type == SUBSHELL || token->type == TK_LBRACE)
&& node->type == FNAME)
if ((token->type == TK_CASE || token->type == TK_WHILE
|| token->type == TK_IF || token->type == TK_UNTIL
|| token->type == TK_FOR || token->type == SUBSHELL
|| token->type == TK_LBRACE) && node->type == FNAME)
node->nest++;
if ((token->type == TK_DONE || token->type == TK_ESAC || token->type == TK_FI
|| token->type == TK_RBRACE || token->type == TK_PAREN_CLOSE)
&& node->type == FNAME && node->nest > 0)
if ((token->type == TK_DONE || token->type == TK_ESAC
|| token->type == TK_FI || token->type == TK_RBRACE
|| token->type == TK_PAREN_CLOSE) && node->type == FNAME
&& node->nest > 0)
node->nest--;
if ((token->type == TK_DONE || token->type == TK_ESAC || token->type == TK_FI
|| token->type == TK_RBRACE || token->type == TK_PAREN_CLOSE)
&& node->type == FNAME && node->nest == 0)
if ((token->type == TK_DONE || token->type == TK_ESAC
|| token->type == TK_FI || token->type == TK_RBRACE
|| token->type == TK_PAREN_CLOSE) && node->type == FNAME
&& node->nest == 0)
{
node->full = 1;
add_one_func(ast, lst);
@ -91,6 +92,5 @@ int add_one_func(t_btree **ast, t_list **lst)
(void)lst;
func_ast = btree_map(*ast, node_copy);
ft_lsteadd(&data_singleton()->lst_func, ft_lstnew(&func_ast, sizeof(*ast)));
DG("arbre ajoute");
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/17 22:17:14 by ariard #+# #+# */
/* Updated: 2017/03/10 17:14:21 by ariard ### ########.fr */
/* Updated: 2017/03/11 15:44:47 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,8 +41,8 @@ int isloop_condition(t_btree **ast, t_list **lst)
if (*ast)
{
node = (*ast)->item;
if (node->type == TK_FOR && (token->type == TK_WORD || token->type == TK_NAME)
&& node->pattern == 0)
if (node->type == TK_FOR && (token->type == TK_WORD
|| token->type == TK_NAME) && node->pattern == 0)
return (1);
}
return (0);
@ -55,11 +55,11 @@ int add_loop_cmd(t_btree **ast, t_list **lst)
token = (*lst)->content;
node = (*ast)->item;
DG("add loop cmd");
if (token->type == TK_DO && node->type == TK_FOR)
node->pattern = 1;
if ((token->type == TK_WHILE || token->type == TK_UNTIL || token->type == TK_FOR)
&& (node->type == TK_WHILE || node->type == TK_UNTIL || node->type == TK_FOR))
if ((token->type == TK_WHILE || token->type == TK_UNTIL
|| token->type == TK_FOR) && (node->type == TK_WHILE
|| node->type == TK_UNTIL || node->type == TK_FOR))
node->nest++;
if (token->type == TK_DONE && (node->type == TK_WHILE
|| node->type == TK_UNTIL || node->type == TK_FOR) && node->nest > 0)
@ -89,18 +89,10 @@ int add_loop_condition(t_btree **ast, t_list **lst)
{
t_astnode *node;
t_token *token;
char **my_tab;
token = (*lst)->content;
node = (*ast)->item;
DG("add word");
if ((my_tab = (char **)malloc(sizeof(char *) * 4)))
{
my_tab[0] = ft_strdup(token->data);
my_tab[1] = (char *)dup_char_esc(token->esc, token->size >> 3);
my_tab[2] = (char *)dup_char_esc(token->esc2, token->size >> 3);
my_tab[3] = NULL;
}
ft_ld_pushback(&node->data.cmd.wordlist, my_tab);
ft_ld_pushback(&node->data.cmd.wordlist,
gen_tab(token->data, token->esc, token->esc2, 1));
return (0);
}

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* add_math.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 15:44:53 by ariard #+# #+# */
/* Updated: 2017/03/11 15:45:21 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int ismath(t_btree **ast, t_list **lst)
@ -21,7 +33,6 @@ int ismath(t_btree **ast, t_list **lst)
return (0);
}
int ismath_expr(t_btree **ast, t_list **lst)
{
t_astnode *node;

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 17:28:31 by ariard #+# #+# */
/* Updated: 2017/03/06 15:56:00 by ariard ### ########.fr */
/* Updated: 2017/03/11 15:46:06 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/17 16:39:05 by ariard #+# #+# */
/* Updated: 2017/03/11 14:51:00 by ariard ### ########.fr */
/* Updated: 2017/03/11 15:52:20 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -36,11 +36,8 @@ int isdir_sep(t_btree **ast, t_list **list)
if (token->type == TK_LESS || token->type == TK_GREAT
|| token->type == TK_GREATAND || token->type == TK_LESSAND
|| token->type == TK_DLESS || token->type == TK_DGREAT)
{
DG("add dir sep");
return (1);
}
}
return (0);
}
@ -74,9 +71,7 @@ int add_redir_word(t_btree **ast, t_list **lst)
node = (*ast)->item;
if (node->data.cmd.redir)
{
DG("add file");
redir = (ft_lstlast(node->data.cmd.redir))->content;
DG("now redir.type :%s", read_state(redir->type));
redir->word = ft_strdup(token->data);
if (redir->type == TK_DLESS)
{
@ -87,19 +82,35 @@ int add_redir_word(t_btree **ast, t_list **lst)
return (0);
}
static int add_redir_type_number(t_btree **ast, t_list **lst)
{
t_redir *temp;
t_redir *temp_heredoc;
t_astnode *node;
t_token *token;
token = (*lst)->content;
node = (*ast)->item;
temp = (ft_lstlast(node->data.cmd.redir))->content;
temp->type = token->type;
if (token->type == TK_DLESS)
{
temp_heredoc = data_singleton()->heredoc_queue->content;
temp_heredoc->n = temp->n;
}
return (0);
}
int add_redir_type(t_btree **ast, t_list **lst)
{
t_astnode *node;
t_token *token;
t_redir redir;
t_redir *temp;
t_redir *temp_heredoc;
if (!*ast)
gen_node(ast);
token = (*lst)->content;
node = (*ast)->item;
DG("node type is :%s", read_state(node->type));
if (!(node->type == TK_IO_NUMBER))
{
redir.n = (token->type == TK_LESS || token->type == TK_DLESS
@ -109,18 +120,11 @@ int add_redir_type(t_btree **ast, t_list **lst)
redir.word = NULL;
ft_lsteadd(&node->data.cmd.redir, ft_lstnew(&redir, sizeof(redir)));
if (token->type == TK_DLESS)
ft_lsteadd(&data_singleton()->heredoc_queue, ft_lstnew(&redir, sizeof(redir)));
ft_lsteadd(&data_singleton()->heredoc_queue,
ft_lstnew(&redir, sizeof(redir)));
}
else
{
temp = (ft_lstlast(node->data.cmd.redir))->content;
temp->type = token->type;
if (token->type == TK_DLESS)
{
temp_heredoc = data_singleton()->heredoc_queue->content;
temp_heredoc->n = temp->n;
}
}
add_redir_type_number(ast, lst);
node->cache = node->type;
node->type = REDIR;
return (0);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 14:54:18 by ariard #+# #+# */
/* Updated: 2017/03/11 15:17:58 by ariard ### ########.fr */
/* Updated: 2017/03/11 15:54:52 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 19:12:07 by ariard #+# #+# */
/* Updated: 2017/03/10 18:10:55 by ariard ### ########.fr */
/* Updated: 2017/03/11 15:55:45 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -32,7 +32,6 @@ int add_sep(t_btree **ast, t_list **lst)
return (add_bang_sep(ast, lst));
if (!*ast)
gen_node(ast);
DG(" flag");
token = (*lst)->content;
new_node = NULL;
gen_node(&new_node);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/24 18:41:50 by ariard #+# #+# */
/* Updated: 2017/03/09 19:46:44 by ariard ### ########.fr */
/* Updated: 2017/03/11 15:56:12 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -34,7 +34,6 @@ int add_subshell_cmd(t_btree **ast, t_list **lst)
t_token *token;
t_astnode *node;
DG("add subshell");
token = (*lst)->content;
node = (*ast)->item;
if (token->type == TK_PAREN_CLOSE && node->type == SUBSHELL)

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/03 15:08:16 by ariard #+# #+# */
/* Updated: 2017/03/07 22:47:38 by ariard ### ########.fr */
/* Updated: 2017/03/11 15:56:38 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,7 +22,8 @@ int isvar(t_btree **ast, t_list **lst)
if (*ast)
{
node = (*ast)->item;
if (node->type != TK_ASSIGNEMENT_WORD && token->type == TK_ASSIGNEMENT_WORD)
if (node->type != TK_ASSIGNEMENT_WORD
&& token->type == TK_ASSIGNEMENT_WORD)
return (1);
}
return (0);

View file

@ -1,11 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* aggregate_sym.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 17:39:18 by ariard #+# #+# */
/* Updated: 2017/03/04 16:16:23 by ariard ### ########.fr */
/* Created: 2017/03/11 15:58:38 by ariard #+# #+# */
/* Updated: 2017/03/11 16:05:58 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -13,7 +14,6 @@
/*
* In case of grammar error, manange it
*
*/
t_aggrematch g_aggrematch[] =
@ -31,7 +31,7 @@ t_aggrematch g_aggrematch[] =
{TK_PAREN_OPEN, CASE_LIST_NS, PATTERN_CASE, 0},
{TK_PAREN_OPEN, TK_PAREN_OPEN, MATH, TK_PAREN_OPEN},
{TK_PAREN_OPEN, CMD_SUPERIOR, OPEN_FUNC, 0},
{TK_ASSIGNEMENT_WORD, CMD_PREFIX,CMD_PREFIX, 0},
{TK_ASSIGNEMENT_WORD, CMD_PREFIX, CMD_PREFIX, 0},
{TK_PIPE, CMD_SUPERIOR, SEQUENCE, CMD_SUPERIOR},
{TK_PIPE, PIPE_SEMI_SEQUENCE, SEQUENCE, PIPE_SEMI_SEQUENCE},
{TK_PIPE, PIPE_CLOSE_SEQUENCE, SEQUENCE, PIPE_CLOSE_SEQUENCE},
@ -42,7 +42,6 @@ t_aggrematch g_aggrematch[] =
{TK_THEN, CONDITION, COMPLETE_CONDITION, CONDITION},
{TK_DONE, CMD_SUPERIOR, DO_GROUP, TK_DO},
{TK_DONE, COMPOUND_LIST, DO_GROUP, TK_DO},
//Esac ?
{TK_ESAC, TK_IN, CASE_CLAUSE, TK_CASE},
{TK_ESAC, CASE_LIST_NS, CASE_CLAUSE, TK_CASE},
{TK_RBRACE, COMPOUND_LIST, BRACE_GROUP, TK_LBRACE},
@ -65,7 +64,6 @@ t_aggrematch g_aggrematch[] =
{TK_OR_IF, CMD_SUPERIOR, AND_OR_MINOR, CMD_SUPERIOR},
{TK_AND_IF, PIPE_SEMI_SEQUENCE, AND_OR_MINOR, PIPE_SEMI_SEQUENCE},
{TK_OR_IF, PIPE_SEMI_SEQUENCE, AND_OR_MINOR, PIPE_SEMI_SEQUENCE},
//watch this
{SEPARATOR_OP, MATH_SUP, CMD_SUPERIOR, MATH_SUP},
{SEPARATOR_OP, CMD_SUPERIOR, SEPARATOR, 0},
{SEPARATOR_OP, COMPOUND_LIST, SEPARATOR, 0},
@ -81,8 +79,6 @@ t_aggrematch g_aggrematch[] =
{LINEBREAK, MATH_SUP, CMD_SUPERIOR, MATH_SUP},
{LINEBREAK, SEPARATOR_OP, SEPARATOR, SEPARATOR_OP},
{LINEBREAK, TK_SEMI, SEQUENTIAL_SEP, TK_SEMI},
//to abstract TK_ESAC
{LINEBREAK, TK_PAREN_CLOSE, FUNC, FNAME},
{LINEBREAK, COMPLETE_COMMANDS, PROGRAM, LINEBREAK},
{LINEBREAK, CMD_SUPERIOR, SEPARATOR_OP, 0},
@ -120,7 +116,6 @@ t_aggrematch g_aggrematch[] =
{NEWLINE_LIST, FOR_WORDLIST, SEQUENTIAL_SEP, 0},
{NEWLINE_LIST, PROGRAM, PROGRAM, PROGRAM},
{SEQUENTIAL_SEP, FOR_WORDLIST, SEQUENTIAL_SEP, FOR_WORDLIST},
//to check
{FILENAME, TK_LESS, IO_FILE, TK_LESS},
{FILENAME, TK_LESSAND, IO_FILE, TK_LESSAND},
{FILENAME, TK_GREAT, IO_FILE, TK_GREAT},
@ -128,16 +123,15 @@ t_aggrematch g_aggrematch[] =
{FILENAME, TK_DGREAT, IO_FILE, TK_DGREAT},
{FILENAME, TK_LESSGREAT, IO_FILE, TK_LESSGREAT},
{FILENAME, TK_CLOBBER, IO_FILE, TK_CLOBBER},
{HERE_END, TK_DLESS, IO_HERE, TK_DLESS},
//to check
{IO_FILE, TK_IO_NUMBER, IO_REDIRECT, TK_IO_NUMBER},
{IO_FILE, ALL, IO_REDIRECT, 0},
{IO_HERE, TK_IO_NUMBER, IO_REDIRECT, TK_IO_NUMBER},
{IO_HERE, ALL, IO_REDIRECT, 0},
{IO_REDIRECT, CMD_SUPERIOR, CMD_SUPERIOR, CMD_SUPERIOR},
{IO_REDIRECT, PIPE_SEMI_SEQUENCE, PIPE_SEMI_SEQUENCE, PIPE_SEMI_SEQUENCE},
{IO_REDIRECT, PIPE_CLOSE_SEQUENCE, PIPE_CLOSE_SEQUENCE, PIPE_CLOSE_SEQUENCE},
{IO_REDIRECT, PIPE_CLOSE_SEQUENCE, PIPE_CLOSE_SEQUENCE,
PIPE_CLOSE_SEQUENCE},
{IO_REDIRECT, COMPOUND_COMMAND, REDIRECT_LIST, REDIRECT_LIST},
{IO_REDIRECT, CMD_SUFFIX, CMD_SUFFIX, CMD_SUFFIX},
{IO_REDIRECT, CMD_NAME, CMD_SUFFIX, 0},
@ -158,14 +152,12 @@ t_aggrematch g_aggrematch[] =
{IO_REDIRECT, TK_ELIF, CMD_PREFIX, 0},
{IO_REDIRECT, TK_ELSE, CMD_PREFIX, 0},
{IO_REDIRECT, TK_PAREN_CLOSE, CMD_PREFIX, 0},
{REDIRECT_LIST, COMPOUND_COMMAND, COMPOUND_COMMAND, COMPOUND_COMMAND},
{CMD_SUFFIX, CMD_WORD, SIMPLE_COMMAND, CMD_PREFIX},
{CMD_SUFFIX, CMD_NAME, SIMPLE_COMMAND, CMD_NAME},
{CMD_SUFFIX, CMD_SUPERIOR, CMD_SUPERIOR, CMD_SUPERIOR},
{CMD_SUFFIX, PIPE_SEMI_SEQUENCE, PIPE_SEMI_SEQUENCE, PIPE_SEMI_SEQUENCE},
{CMD_SUFFIX, PIPE_CLOSE_SEQUENCE, PIPE_CLOSE_SEQUENCE, PIPE_CLOSE_SEQUENCE},
//to abstract
{CMD_PREFIX, LINEBREAK, SIMPLE_COMMAND, 0},
{CMD_PREFIX, TK_PAREN_OPEN, SIMPLE_COMMAND, 0},
{CMD_PREFIX, TK_LBRACE, SIMPLE_COMMAND, 0},
@ -174,7 +166,7 @@ t_aggrematch g_aggrematch[] =
{CMD_PREFIX, SEPARATOR_OP, SIMPLE_COMMAND, 0},
{CMD_PREFIX, NEWLINE_LIST, SIMPLE_COMMAND, 0},
{CMD_PREFIX, TK_WHILE, SIMPLE_COMMAND, 0},
{CMD_PREFIX, TK_UNTIL,SIMPLE_COMMAND, 0},
{CMD_PREFIX, TK_UNTIL, SIMPLE_COMMAND, 0},
{CMD_PREFIX, TK_DO, SIMPLE_COMMAND, 0},
{CMD_PREFIX, TK_THEN, SIMPLE_COMMAND, TK_BANG},
{CMD_PREFIX, TK_IF, SIMPLE_COMMAND, 0},
@ -186,9 +178,7 @@ t_aggrematch g_aggrematch[] =
{CMD_PREFIX, TK_PIPE, SIMPLE_COMMAND, 0},
{CMD_PREFIX, SEQUENCE, SIMPLE_COMMAND, 0},
{CMD_PREFIX, COMPOUND_LIST, SIMPLE_COMMAND, 0},
{CMD_WORD, CMD_PREFIX, SIMPLE_COMMAND, CMD_PREFIX},
//to check
{CMD_NAME, LINEBREAK, CMD_SUPERIOR, 0},
{CMD_NAME, TK_PAREN_OPEN, CMD_SUPERIOR, 0},
{CMD_NAME, TK_LBRACE, CMD_SUPERIOR, 0},
@ -251,7 +241,6 @@ t_aggrematch g_aggrematch[] =
{AND_OR_MINOR, AND_OR_MAJOR, AND_OR_MAJOR, 0},
{AND_OR_MINOR, TK_BANG, AND_OR_MAJOR, TK_BANG},
{COMMAND, SEQUENCE, PIPE_SEMI_SEQUENCE, 0},
// watch
{COMMAND, COMPOUND_LIST, PIPE_SEMI_SEQUENCE, 0},
{COMMAND, CASE_LIST_NS, PIPE_SEMI_SEQUENCE, 0},
{COMMAND, TK_WHILE, PIPE_SEMI_SEQUENCE, 0},
@ -354,7 +343,6 @@ t_aggrematch g_aggrematch[] =
{PIPELINE, TK_PAREN_OPEN, AND_OR, 0},
{PIPELINE, TK_LBRACE, AND_OR, 0},
{PIPELINE, COMPLETE_COMMANDS, AND_OR, 0},
// {PIPELINE, LINEBREAK, AND_OR, AND_OR},
{PIPELINE, SEPARATOR_OP, AND_OR, 0},
{PIPELINE, COMPLETE_CONDITION, AND_OR, 0},
{PIPELINE, CONDITION, AND_OR, 0},
@ -386,7 +374,8 @@ t_aggrematch g_aggrematch[] =
{COMPLETE_COMMAND, NEWLINE_LIST, COMPLETE_COMMANDS, COMPLETE_COMMANDS},
{COMPLETE_COMMAND, LINEBREAK, COMPLETE_COMMANDS, 0},
{COMPLETE_COMMAND, COMPLETE_COMMANDS, COMPLETE_COMMANDS, 0},
{COMPLETE_COMMANDS, COMPLETE_COMMANDS, COMPLETE_COMMANDS, COMPLETE_COMMANDS},
{COMPLETE_COMMANDS, COMPLETE_COMMANDS, COMPLETE_COMMANDS,
COMPLETE_COMMANDS},
{0, 0, 0, 0},
};
@ -405,7 +394,6 @@ int aggregate_sym(t_list **stack, t_sym *new_sym, t_parstate *state)
{
if (*new_sym == g_aggrematch[i].top
&& MATCH_STACK(*head, g_aggrematch[i].under))
{
// DG("MATCH : %s", read_state(g_aggrematch[i].new_sym));
*new_sym = g_aggrematch[i].new_sym;

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 18:32:59 by ariard #+# #+# */
/* Updated: 2017/03/10 15:34:58 by ariard ### ########.fr */
/* Updated: 2017/03/11 16:08:26 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -60,7 +60,6 @@ static int isseparator(t_token *token, int cache)
|| cache == TK_NEWLINE || cache == TK_THEN || cache == TK_IN
|| cache == TK_DSEMI))
return (0);
//check cache == WORD
return (1);
}
@ -72,7 +71,6 @@ int build_tree(t_btree **ast, t_list **lst)
i = 0;
token = (*lst)->content;
//check bug de cache case ?
if (token->type == TK_PAREN_OPEN && cache != TK_IN && cache != TK_DSEMI
&& cache != TK_WORD)
token->type = SUBSHELL;
@ -80,9 +78,6 @@ int build_tree(t_btree **ast, t_list **lst)
{
if ((isseparator(token, cache) && g_treematch[i].type == token->type))
{
DG("func TK : '%s' TK : '%s'",
read_state(g_treematch[i].type) ,read_state(token->type));
cache = token->type;
return (g_treematch[i].add(ast, lst));
}

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 20:15:35 by ariard #+# #+# */
/* Updated: 2017/03/09 16:37:14 by ariard ### ########.fr */
/* Updated: 2017/03/11 16:10:56 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -81,7 +81,7 @@ int error_syntax(t_list **lst, t_parser *parser,
return (0);
}
int error_EOF(t_list **lst, t_parser *parser, t_btree **ast)
int error_eof(t_list **lst, t_parser *parser, t_btree **ast)
{
ft_putstr_fd("syntax error near unexpected EOF", 2);
instruction_free(lst, parser, ast);

View file

@ -5,7 +5,8 @@
/* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 16:26:30 by ariard #+# #+# */
/* Created: 2017/03/11 16:11:21 by ariard #+# #+# */
/* Updated: 2017/03/11 16:17:10 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -70,7 +71,6 @@ t_stackmatch g_stackmatch[] =
{TK_DSEMI, PIPE_SEMI_SEQUENCE},
{TK_DSEMI, PIPE_CLOSE_SEQUENCE},
{TK_DSEMI, SEQUENCE},
// watch!
{TK_LESS, TK_IO_NUMBER},
{TK_LESS, REDIRECT_LIST},
{TK_LESS, CMD_SUFFIX},
@ -99,7 +99,6 @@ t_stackmatch g_stackmatch[] =
{TK_LESS, COMPLETE_CONDITION},
{TK_LESS, CONDITION},
{TK_LESS, COMPOUND_LIST},
// watch !
{TK_LESS, CMD_SUPERIOR},
{TK_LESS, AND_OR_MAJOR},
{TK_GREAT, TK_IO_NUMBER},
@ -130,11 +129,8 @@ t_stackmatch g_stackmatch[] =
{TK_GREAT, COMPLETE_CONDITION},
{TK_GREAT, CONDITION},
{TK_GREAT, COMPOUND_LIST},
// watch !
//duplicate and extend
{TK_GREAT, CMD_SUPERIOR},
{TK_GREAT, AND_OR_MAJOR},
{TK_DLESS, TK_IO_NUMBER},
{TK_DLESS, REDIRECT_LIST},
{TK_DLESS, CMD_SUFFIX},
@ -163,10 +159,8 @@ t_stackmatch g_stackmatch[] =
{TK_DLESS, COMPLETE_CONDITION},
{TK_DLESS, CONDITION},
{TK_DLESS, COMPOUND_LIST},
// watch !
{TK_DLESS, CMD_SUPERIOR},
{TK_DLESS, AND_OR_MAJOR},
{TK_DGREAT, TK_IO_NUMBER},
{TK_DGREAT, REDIRECT_LIST},
{TK_DGREAT, CMD_SUFFIX},
@ -195,10 +189,8 @@ t_stackmatch g_stackmatch[] =
{TK_DGREAT, COMPLETE_CONDITION},
{TK_DGREAT, CONDITION},
{TK_DGREAT, COMPOUND_LIST},
// watch !
{TK_DGREAT, CMD_SUPERIOR},
{TK_DGREAT, AND_OR_MAJOR},
{TK_LESSAND, TK_IO_NUMBER},
{TK_LESSAND, REDIRECT_LIST},
{TK_LESSAND, CMD_SUFFIX},
@ -227,10 +219,8 @@ t_stackmatch g_stackmatch[] =
{TK_LESSAND, COMPLETE_CONDITION},
{TK_LESSAND, CONDITION},
{TK_LESSAND, COMPOUND_LIST},
// watch !
{TK_LESSAND, CMD_SUPERIOR},
{TK_LESSAND, AND_OR_MAJOR},
{TK_GREATAND, TK_IO_NUMBER},
{TK_GREATAND, REDIRECT_LIST},
{TK_GREATAND, CMD_SUFFIX},
@ -259,11 +249,8 @@ t_stackmatch g_stackmatch[] =
{TK_GREATAND, COMPLETE_CONDITION},
{TK_GREATAND, CONDITION},
{TK_GREATAND, COMPOUND_LIST},
// watch !
{TK_GREATAND, CMD_SUPERIOR},
{TK_GREATAND, AND_OR_MAJOR},
{TK_IF, LINEBREAK},
{TK_IF, TK_BANG},
{TK_IF, TK_PAREN_OPEN},
@ -272,7 +259,6 @@ t_stackmatch g_stackmatch[] =
{TK_IF, SEPARATOR_OP},
{TK_IF, NEWLINE_LIST},
{TK_IF, SEQUENCE},
// watch !
{TK_IF, TK_WHILE},
{TK_IF, FUNC_NAME},
{TK_IF, TK_UNTIL},
@ -328,7 +314,6 @@ t_stackmatch g_stackmatch[] =
{TK_CASE, NEWLINE_LIST},
{TK_CASE, SEPARATOR_OP},
{TK_CASE, SEQUENCE},
// watch !
{TK_IN, TK_WORD},
{TK_IN, NAME},
{TK_ESAC, CASE_LIST_NS},
@ -342,7 +327,6 @@ t_stackmatch g_stackmatch[] =
{TK_WHILE, SEPARATOR_OP},
{TK_WHILE, NEWLINE_LIST},
{TK_WHILE, SEQUENCE},
// watch !
{TK_WHILE, TK_DO},
{TK_WHILE, TK_PAREN_CLOSE},
{TK_WHILE, TK_WHILE},
@ -364,7 +348,6 @@ t_stackmatch g_stackmatch[] =
{TK_UNTIL, SEPARATOR_OP},
{TK_UNTIL, NEWLINE_LIST},
{TK_UNTIL, SEQUENCE},
// watch !
{TK_UNTIL, TK_DO},
{TK_UNTIL, TK_PAREN_CLOSE},
{TK_UNTIL, TK_WHILE},
@ -386,7 +369,6 @@ t_stackmatch g_stackmatch[] =
{TK_FOR, SEPARATOR_OP},
{TK_FOR, NEWLINE_LIST},
{TK_FOR, SEQUENCE},
// watch !
{TK_FOR, TK_DO},
{TK_FOR, TK_PAREN_CLOSE},
{TK_FOR, TK_WHILE},
@ -407,7 +389,6 @@ t_stackmatch g_stackmatch[] =
{TK_LBRACE, SEPARATOR_OP},
{TK_LBRACE, NEWLINE_LIST},
{TK_LBRACE, SEQUENCE},
// watch !
{TK_LBRACE, AND_OR_MAJOR},
{TK_LBRACE, TK_WHILE},
{TK_LBRACE, FUNC_NAME},
@ -476,7 +457,6 @@ t_stackmatch g_stackmatch[] =
{TK_PAREN_OPEN, NEWLINE_LIST},
{TK_PAREN_OPEN, SEQUENCE},
{TK_PAREN_OPEN, FUNC_NAME},
// watch !
{TK_PAREN_OPEN, AND_OR_MAJOR},
{TK_PAREN_OPEN, TK_WHILE},
{TK_PAREN_OPEN, TK_LBRACE},
@ -663,7 +643,6 @@ t_stackmatch g_stackmatch[] =
{IO_HERE, COMPLETE_CONDITION},
{IO_HERE, CONDITION},
{IO_HERE, COMPOUND_LIST},
// watch !
{FILENAME, TK_LESS},
{FILENAME, TK_LESSAND},
{FILENAME, TK_GREAT},
@ -698,7 +677,6 @@ t_stackmatch g_stackmatch[] =
{IO_FILE, COMPLETE_CONDITION},
{IO_FILE, CONDITION},
{IO_FILE, COMPOUND_LIST},
// watch !
{IO_REDIRECT, REDIRECT_LIST},
{IO_REDIRECT, CMD_SUPERIOR},
{IO_REDIRECT, CMD_SUFFIX},
@ -727,7 +705,6 @@ t_stackmatch g_stackmatch[] =
{IO_REDIRECT, COMPLETE_CONDITION},
{IO_REDIRECT, CONDITION},
{IO_REDIRECT, COMPOUND_LIST},
// watch !/
{REDIRECT_LIST, COMPOUND_COMMAND},
{CMD_SUFFIX, CMD_WORD},
{CMD_SUFFIX, CMD_NAME},
@ -754,7 +731,6 @@ t_stackmatch g_stackmatch[] =
{CMD_PREFIX, COMPLETE_CONDITION},
{CMD_PREFIX, CONDITION},
{CMD_PREFIX, COMPOUND_LIST},
// watch !
{CMD_WORD, CMD_PREFIX},
{CMD_NAME, COMPLETE_COMMANDS},
{CMD_NAME, LINEBREAK},
@ -768,7 +744,6 @@ t_stackmatch g_stackmatch[] =
{CMD_NAME, AND_OR_MAJOR},
{CMD_NAME, CONDITION},
{CMD_NAME, COMPOUND_LIST},
// watch !
{CMD_NAME, AND_OR_MAJOR},
{CMD_NAME, TK_WHILE},
{CMD_NAME, FUNC_NAME},
@ -783,7 +758,6 @@ t_stackmatch g_stackmatch[] =
{CMD_NAME, CASE_LIST_NS},
{CMD_NAME, COMPLETE_CONDITION},
{CMD_NAME, CONDITION},
{CMD_SUPERIOR, TK_WHILE},
{CMD_SUPERIOR, FUNC_NAME},
{CMD_SUPERIOR, TK_UNTIL},
@ -806,9 +780,7 @@ t_stackmatch g_stackmatch[] =
{CMD_SUPERIOR, NEWLINE_LIST},
{CMD_SUPERIOR, TK_PIPE},
{CMD_SUPERIOR, SEQUENCE},
// watch !
{CMD_SUPERIOR, AND_OR_MAJOR},
{CLOSE_FUNC, CMD_SUPERIOR},
{CLOSE_FUNC, OPEN_FUNC},
{MATH, LINEBREAK},
@ -823,7 +795,6 @@ t_stackmatch g_stackmatch[] =
{MATH_SUP, NEWLINE_LIST},
{MATH_SUP, SEPARATOR},
{MATH_SUP, SEPARATOR_OP},
{SIMPLE_COMMAND, TK_WHILE},
{SIMPLE_COMMAND, TK_UNTIL},
{SIMPLE_COMMAND, TK_DO},
@ -844,7 +815,6 @@ t_stackmatch g_stackmatch[] =
{SIMPLE_COMMAND, SEPARATOR_OP},
{SIMPLE_COMMAND, NEWLINE_LIST},
{SIMPLE_COMMAND, SEQUENCE},
// watch !
{SIMPLE_COMMAND, AND_OR_MAJOR},
{DO_GROUP, CMD_SUPERIOR},
{DO_GROUP, COMPOUND_LIST},
@ -874,7 +844,6 @@ t_stackmatch g_stackmatch[] =
{BRACE_GROUP, SEPARATOR_OP},
{BRACE_GROUP, NEWLINE_LIST},
{BRACE_GROUP, SEQUENCE},
// watch !
{FNAME, LINEBREAK},
{FNAME, TK_PAREN_OPEN},
{FNAME, TK_LBRACE},
@ -883,7 +852,6 @@ t_stackmatch g_stackmatch[] =
{FNAME, SEPARATOR_OP},
{FNAME, NEWLINE_LIST},
{FNAME, SEQUENCE},
// watch !
{FUNCTION_BODY, FUNC},
{FUNCTION_DEFINITION, LINEBREAK},
{FUNCTION_DEFINITION, TK_PAREN_OPEN},
@ -893,7 +861,6 @@ t_stackmatch g_stackmatch[] =
{FUNCTION_DEFINITION, SEPARATOR_OP},
{FUNCTION_DEFINITION, NEWLINE_LIST},
{FUNCTION_DEFINITION, SEQUENCE},
// watch !
{UNTIL_CLAUSE, LINEBREAK},
{UNTIL_CLAUSE, TK_PAREN_OPEN},
{UNTIL_CLAUSE, TK_LBRACE},
@ -922,7 +889,6 @@ t_stackmatch g_stackmatch[] =
{WHILE_CLAUSE, SEPARATOR_OP},
{WHILE_CLAUSE, NEWLINE_LIST},
{WHILE_CLAUSE, SEQUENCE},
// watch !
{WHILE_CLAUSE, TK_DO},
{WHILE_CLAUSE, TK_PAREN_CLOSE},
{WHILE_CLAUSE, TK_WHILE},
@ -946,7 +912,6 @@ t_stackmatch g_stackmatch[] =
{IF_CLAUSE, SEPARATOR_OP},
{IF_CLAUSE, NEWLINE_LIST},
{IF_CLAUSE, SEQUENCE},
// watch !
{IF_CLAUSE, TK_DO},
{IF_CLAUSE, TK_PAREN_CLOSE},
{IF_CLAUSE, TK_WHILE},
@ -970,7 +935,6 @@ t_stackmatch g_stackmatch[] =
{BRACE_CLAUSE, SEPARATOR_OP},
{BRACE_CLAUSE, NEWLINE_LIST},
{BRACE_CLAUSE, SEQUENCE},
// watch !
{BRACE_CLAUSE, TK_DO},
{BRACE_CLAUSE, TK_PAREN_CLOSE},
{BRACE_CLAUSE, TK_WHILE},
@ -999,7 +963,6 @@ t_stackmatch g_stackmatch[] =
{CASE_CLAUSE, SEPARATOR_OP},
{CASE_CLAUSE, NEWLINE_LIST},
{CASE_CLAUSE, SEQUENCE},
// watch !
{CASE_CLAUSE, TK_PAREN_CLOSE},
{CASE_CLAUSE, CASE_LIST_NS},
{CASE_CLAUSE, TK_DO},
@ -1015,7 +978,6 @@ t_stackmatch g_stackmatch[] =
{CASE_CLAUSE, COMPLETE_CONDITION},
{CASE_CLAUSE, CONDITION},
{CASE_CLAUSE, AND_OR_MAJOR},
{WORDLIST, IN},
{IN, LINEBREAK},
{NAME, TK_FOR},
@ -1028,7 +990,6 @@ t_stackmatch g_stackmatch[] =
{FOR_CLAUSE, SEPARATOR_OP},
{FOR_CLAUSE, NEWLINE_LIST},
{FOR_CLAUSE, SEQUENCE},
// watch !
{FOR_CLAUSE, TK_DO},
{FOR_CLAUSE, TK_PAREN_CLOSE},
{FOR_CLAUSE, TK_WHILE},
@ -1066,7 +1027,6 @@ t_stackmatch g_stackmatch[] =
{SUBSHELL, NEWLINE_LIST},
{SUBSHELL, SEQUENCE},
{SUBSHELL, TK_LBRACE},
// watch !
{SUBSHELL, SEPARATOR_OP},
{SUBSHELL, NEWLINE_LIST},
{SUBSHELL, TK_DO},
@ -1091,7 +1051,6 @@ t_stackmatch g_stackmatch[] =
{COMPOUND_COMMAND, SEPARATOR_OP},
{COMPOUND_COMMAND, NEWLINE_LIST},
{COMPOUND_COMMAND, SEQUENCE},
// watch !
{COMPOUND_COMMAND, FUNC},
{COMPOUND_COMMAND, TK_DO},
{COMPOUND_COMMAND, TK_PAREN_CLOSE},
@ -1129,7 +1088,6 @@ t_stackmatch g_stackmatch[] =
{COMMAND, SEQUENCE},
{COMMAND, AND_OR_MAJOR},
{AND_OR_MINOR, SEQUENCE},
// watch !
{AND_OR_MINOR, LINEBREAK},
{AND_OR_MINOR, TK_BANG},
{AND_OR_MINOR, TK_PAREN_OPEN},

View file

@ -5,7 +5,8 @@
/* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */
/* Created: 2017/03/11 16:17:38 by ariard #+# #+# */
/* Updated: 2017/03/11 16:18:35 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -49,7 +50,6 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser)
push_stack(&parser->stack, *parser->new_sym);
}
// ft_read_stack(parser->stack);
DG("\n");
if (*(head = (parser->stack)->content) == PROGRAM)
parser->state = SUCCESS;
else

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 16:21:05 by ariard #+# #+# */
/* Updated: 2017/03/10 13:33:29 by jhalford ### ########.fr */
/* Updated: 2017/03/11 16:20:21 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,10 +25,8 @@ int pop_heredoc(t_list **lst)
{
head = data_singleton()->heredoc_queue->content;
temp = data_singleton()->heredoc_queue;
DG("compare %s with %s", (char *)token->data, head->word);
if (head && token)
{
DG();
if (ft_strcmp((char *)token->data, head->word) == 0)
{
temp2 = temp->next;
@ -36,10 +34,8 @@ int pop_heredoc(t_list **lst)
data_singleton()->heredoc_queue = temp2;
}
else
{
DG("joining [%s] to heredoc", (char*)token->data);
head->heredoc_data = ft_strjoin(head->heredoc_data, token->data);
}
head->heredoc_data = ft_strjoin(head->heredoc_data,
token->data);
}
ft_lstdel(lst, &token_free);
return (1);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/21 16:14:04 by ariard #+# #+# */
/* Updated: 2017/03/09 16:49:14 by ariard ### ########.fr */
/* Updated: 2017/03/11 16:20:31 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 19:12:44 by ariard #+# #+# */
/* Updated: 2017/03/07 15:09:32 by ariard ### ########.fr */
/* Updated: 2017/03/11 16:21:01 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 17:58:34 by ariard #+# #+# */
/* Updated: 2017/03/10 18:46:59 by ariard ### ########.fr */
/* Updated: 2017/03/11 16:22:18 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -117,7 +117,6 @@ t_prodmatch g_prodmatch[] =
{TK_AMP, LIST, SEPARATOR_OP},
{TK_AMP, PIPE_SEMI_SEQUENCE, SEPARATOR_OP},
{TK_AMP, PIPE_CLOSE_SEQUENCE, SEPARATOR_OP},
{0, 0, 0},
};

View file

@ -6,16 +6,14 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 16:48:30 by ariard #+# #+# */
/* Updated: 2017/03/03 14:28:09 by ariard ### ########.fr */
/* Updated: 2017/03/11 16:22:32 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
//int push_stack(t_sym *stack, t_sym new_sym)
int push_stack(t_list **stack, t_sym sym)
{
ft_lstadd(stack, ft_lstnew(&sym, sizeof(sym)));
// *stack = sym;
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 18:57:44 by ariard #+# #+# */
/* Updated: 2017/03/10 17:49:28 by ariard ### ########.fr */
/* Updated: 2017/03/11 16:23:21 by ariard ### ########.fr */
/* */
/* ************************************************************************** */