fix merge

This commit is contained in:
wescande 2017-03-15 03:53:37 +01:00
commit cdfac4c3fc
46 changed files with 152 additions and 399 deletions

View file

@ -6,7 +6,7 @@
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ # # By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2016/08/29 21:32:58 by wescande #+# #+# # # Created: 2016/08/29 21:32:58 by wescande #+# #+# #
# Updated: 2017/03/14 12:34:49 by gwojda ### ########.fr # # Updated: 2017/03/14 21:59:22 by ariard ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -39,6 +39,7 @@ builtin/builtin_exit.c\
builtin/builtin_export.c\ builtin/builtin_export.c\
builtin/builtin_hash.c\ builtin/builtin_hash.c\
builtin/builtin_history.c\ builtin/builtin_history.c\
builtin/builtin_math.c\
builtin/builtin_read.c\ builtin/builtin_read.c\
builtin/builtin_setenv.c\ builtin/builtin_setenv.c\
builtin/builtin_unset.c\ builtin/builtin_unset.c\
@ -72,7 +73,6 @@ exec/exec_case_branch.c\
exec/exec_elif.c\ exec/exec_elif.c\
exec/exec_else.c\ exec/exec_else.c\
exec/exec_leaf.c\ exec/exec_leaf.c\
exec/exec_math.c\
exec/exec_or_if.c\ exec/exec_or_if.c\
exec/exec_pipe.c\ exec/exec_pipe.c\
exec/exec_reset.c\ exec/exec_reset.c\
@ -277,7 +277,6 @@ parser/add_cmd.c\
parser/add_condition.c\ parser/add_condition.c\
parser/add_func.c\ parser/add_func.c\
parser/add_loop.c\ parser/add_loop.c\
parser/add_math.c\
parser/add_number.c\ parser/add_number.c\
parser/add_redir.c\ parser/add_redir.c\
parser/add_sep.c\ parser/add_sep.c\

View file

@ -3,9 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* builtin.h :+: :+: :+: */ /* builtin.h :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 17:21:56 by jhalford #+# #+# */ /* Created: 2017/03/14 22:59:57 by jhalford #+# #+# */
/* Updated: 2017/03/15 00:48:28 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -32,5 +33,6 @@ int builtin_fg(const char *path, char *const av[], char *const envp[]);
int builtin_bg(const char *path, char *const av[], char *const envp[]); int builtin_bg(const char *path, char *const av[], char *const envp[]);
int builtin_history(const char *path, char *const av[], char *const envp[]); int builtin_history(const char *path, char *const av[], char *const envp[]);
int builtin_hash(const char *path, char *const av[], char *const envp[]); int builtin_hash(const char *path, char *const av[], char *const envp[]);
int builtin_math(const char *path, char *const av[], char *const envp[]);
#endif #endif

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */ /* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
/* Updated: 2017/03/14 21:17:31 by jhalford ### ########.fr */ /* Updated: 2017/03/15 01:07:00 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -62,7 +62,7 @@ struct s_data_cond
struct s_data_list struct s_data_list
{ {
t_ld *list_word; t_ld *token;
t_btree *content; t_btree *content;
}; };

View file

@ -104,7 +104,6 @@ int add_cmd(t_btree **ast, t_list **lst);
int add_file(t_btree **ast, t_list **lst); int add_file(t_btree **ast, t_list **lst);
int add_loop_cmd(t_btree **ast, t_list **lst); int add_loop_cmd(t_btree **ast, t_list **lst);
int add_loop_sep(t_btree **ast, t_list **lst); int add_loop_sep(t_btree **ast, t_list **lst);
int add_loop_condition(t_btree **ast, t_list **lst);
int add_condition_cmd(t_btree **ast, t_list **lst); int add_condition_cmd(t_btree **ast, t_list **lst);
int add_condition_sep(t_btree **ast, t_list **lst); int add_condition_sep(t_btree **ast, t_list **lst);
int add_branch(t_btree **ast, t_list **lst); int add_branch(t_btree **ast, t_list **lst);
@ -127,7 +126,6 @@ int add_bang_sep(t_btree **ast, t_list **lst);
int add_if(t_btree **ast, t_list **lst); int add_if(t_btree **ast, t_list **lst);
int isloop(t_btree **ast, t_list **lst); int isloop(t_btree **ast, t_list **lst);
int isloop_condition(t_btree **ast, t_list **lst);
int iscase(t_btree **ast, t_list **lst); int iscase(t_btree **ast, t_list **lst);
int iscase_pattern(t_btree **ast, t_list **lst); int iscase_pattern(t_btree **ast, t_list **lst);
int iscase_branch(t_btree **ast, t_list **lst); int iscase_branch(t_btree **ast, t_list **lst);
@ -142,8 +140,6 @@ int isdir_sep(t_btree **ast, t_list **list);
int isdir_word(t_btree **ast, t_list **list); int isdir_word(t_btree **ast, t_list **list);
int isnull(t_btree **ast, t_list **list); int isnull(t_btree **ast, t_list **list);
int isionumber(t_btree **ast, t_list **lst); int isionumber(t_btree **ast, t_list **lst);
int ismath(t_btree **ast, t_list **lst);
int ismath_expr(t_btree **ast, t_list **lst);
int isbang(t_btree **ast, t_list **lst); int isbang(t_btree **ast, t_list **lst);
int isbang_sep(t_btree **ast, t_list **lst); int isbang_sep(t_btree **ast, t_list **lst);
@ -171,7 +167,6 @@ struct s_cmd
{ {
t_list *redir; t_list *redir;
t_ld *token; t_ld *token;
t_ld *wordlist;
}; };
union u_astdata union u_astdata

View file

@ -6,8 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */ /* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */
/* Updated: 2017/03/14 20:25:53 by jhalford ### ########.fr */ /* Updated: 2017/03/14 22:53:17 by ariard ### ########.fr */
/* Updated: 2017/03/07 18:35:11 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -198,9 +197,6 @@ enum e_sym
OPEN_FUNC, OPEN_FUNC,
CLOSE_FUNC, CLOSE_FUNC,
CLOSE_LIST, CLOSE_LIST,
MATH,
MATH_PLUS,
MATH_SUP,
REDIR, REDIR,
CMD, CMD,
HEREDOCDATA, HEREDOCDATA,

View file

@ -6,17 +6,25 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 10:58:49 by ariard #+# #+# */ /* Created: 2017/03/07 10:58:49 by ariard #+# #+# */
/* Updated: 2017/03/14 00:55:04 by ariard ### ########.fr */ /* Updated: 2017/03/14 22:45:23 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
static int get_math(char *stream, char **var, char **value, char **operator) static int init_math(char **var, char **value, char **operator, char **operand)
{
*var = NULL;
*value = NULL;
*operator = NULL;
*operand = NULL;
return (0);
}
static int get_value(char **var, char **value)
{ {
char *temp; char *temp;
*var = ft_strduptr(stream, &ft_isalpha);
temp = ft_sstrstr(data_singleton()->local_var, *var); temp = ft_sstrstr(data_singleton()->local_var, *var);
if (temp) if (temp)
{ {
@ -30,21 +38,21 @@ static int get_math(char *stream, char **var, char **value, char **operator)
} }
else else
*value = ft_itoa(0); *value = ft_itoa(0);
stream += ft_strlen(*var);
*operator = ft_strdup(stream);
return (0); return (0);
} }
static int do_math(char **value, char *operator) static int do_math(char **value, char *operator, char *operand)
{ {
long ope1; long ope1;
long ope2; long ope2;
ope1 = ft_atoi(*value); ope1 = ft_atoi(*value);
if (operator[2]) if (operand)
ope2 = ft_atoi(&operator[2]); ope2 = ft_atoi(operand);
else else
ope2 = 0; ope2 = 0;
if (ft_strlen(operator) > 1)
return (0);
if ((operator[0] == '/' || operator[0] == '%') && ope2 == 0) if ((operator[0] == '/' || operator[0] == '%') && ope2 == 0)
ope1 = 0; ope1 = 0;
else else
@ -60,22 +68,22 @@ static int do_math(char **value, char *operator)
return (0); return (0);
} }
int exec_math(t_btree **ast) int builtin_math(const char *path, char *const av[], char *const envp[])
{ {
t_astnode *node;
char **av;
char *var; char *var;
char *value; char *value;
char *operator; char *operator;
char *operand;
node = (*ast)->item; (void)path;
av = token_to_argv(node->data.cmd.wordlist, 1); (void)envp;
DG("before get math : %s", av[0]); init_math(&var, &value, &operator, &operand);
get_math(av[0], &var, &value, &operator); var = av[1];
DG("before do math var %s value %s operator %s", var, value, operator); get_value(&var, &value);
do_math(&value, operator); operator = av[2];
DG("before setenv %s", value); operand = av[3];
// DG("math %s %s %s", var, operator, operand);
do_math(&value, operator, operand);
builtin_setenv("setenv", (char *[]){"local", var, value, 0}, data_singleton()->local_var); builtin_setenv("setenv", (char *[]){"local", var, value, 0}, data_singleton()->local_var);
DG("after setenv");
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */ /* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
/* Updated: 2017/03/14 21:40:07 by jhalford ### ########.fr */ /* Updated: 2017/03/15 02:12:56 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -31,7 +31,7 @@ int builtin_setenv(const char *path, char *const av[], char *const envp[])
} }
else else
{ {
str = ft_str3join(av[0], "=", av[1]); str = ft_str3join(av[0], "=", av[2]);
while ((*env) && (*env)[i]) while ((*env) && (*env)[i])
{ {
if (ft_strcmp((*env)[i], av[0]) == '=') if (ft_strcmp((*env)[i], av[0]) == '=')

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 13:09:57 by jhalford #+# #+# */ /* Created: 2016/12/13 13:09:57 by jhalford #+# #+# */
/* Updated: 2017/03/13 22:52:32 by jhalford ### ########.fr */ /* Updated: 2017/03/14 22:32:24 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -28,6 +28,7 @@ t_stof g_builtin[] =
{"read", &builtin_read}, {"read", &builtin_read},
{"hash", &builtin_hash}, {"hash", &builtin_hash},
{"history", &builtin_history}, {"history", &builtin_history},
{"math", &builtin_math},
{NULL, NULL}, {NULL, NULL},
}; };

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 20:33:45 by wescande #+# #+# */ /* Created: 2017/03/07 20:33:45 by wescande #+# #+# */
/* Updated: 2017/03/07 20:34:48 by wescande ### ########.fr */ /* Updated: 2017/03/15 01:21:45 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,23 +17,20 @@ int exec_case_branch(t_btree **ast)
t_astnode *node; t_astnode *node;
char **av; char **av;
t_exec *exec; t_exec *exec;
int i;
DG("exec branch case");
exec = &data_singleton()->exec; exec = &data_singleton()->exec;
if (EXEC_IS_CASE_BRANCH(exec->attrs)) if (EXEC_IS_CASE_BRANCH(exec->attrs))
return (0); return (0);
node = (*ast)->item; node = (*ast)->item;
av = token_to_argv(node->data.cmd.wordlist, 1); av = token_to_argv(node->data.cmd.token, 1);
i = 0; DG("compare pattern %s ", av[0]);
while (av[i]) DG("and case %s", ((char **)exec->case_pattern)[0]);
{ DG();
if (ft_strcmp(av[i], ((char **)exec->case_pattern)[0]) == 0) if (ft_strcmp(av[0], ((char **)exec->case_pattern)[0]) == 0)
{ {
exec->attrs |= EXEC_CASE_BRANCH; exec->attrs |= EXEC_CASE_BRANCH;
ft_exec(&(*ast)->right); ft_exec(&(*ast)->right);
break ;
}
i++;
} }
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/06 18:08:53 by ariard #+# #+# */ /* Created: 2017/02/06 18:08:53 by ariard #+# #+# */
/* Updated: 2017/03/04 17:45:29 by ariard ### ########.fr */ /* Updated: 2017/03/15 02:04:57 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -1,4 +1,4 @@
/* ************************************************************************** */ /*ss ************************************************************************** */
/* */ /* */
/* ::: :::::::: */ /* ::: :::::::: */
/* exec_leaf.c :+: :+: :+: */ /* exec_leaf.c :+: :+: :+: */
@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */ /* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
/* Updated: 2017/03/14 20:26:49 by jhalford ### ########.fr */ /* Updated: 2017/03/15 02:04:30 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 11:12:05 by ariard #+# #+# */ /* Created: 2017/03/07 11:12:05 by ariard #+# #+# */
/* Updated: 2017/03/14 21:09:45 by jhalford ### ########.fr */ /* Updated: 2017/03/14 23:55:40 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -30,6 +30,8 @@ int exec_var(t_btree **ast)
node = (*ast)->item; node = (*ast)->item;
av = token_to_argv(node->data.cmd.token, 1); av = token_to_argv(node->data.cmd.token, 1);
set_var(av[0], &var, &value); set_var(av[0], &var, &value);
if (ft_getenv(data_singleton()->env, var))
return (0);
builtin_setenv("internal", (char*[]){"local", var, value, 0}, NULL); builtin_setenv("internal", (char*[]){"local", var, value, 0}, NULL);
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */ /* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */
/* Updated: 2017/03/14 00:49:02 by ariard ### ########.fr */ /* Updated: 2017/03/15 02:04:38 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -29,7 +29,6 @@ t_itof g_execmap[] =
{TK_CASE, &exec_leaf}, {TK_CASE, &exec_leaf},
{TK_PAREN_OPEN, &exec_case_branch}, {TK_PAREN_OPEN, &exec_case_branch},
{TK_ASSIGNMENT_WORD, &exec_var}, {TK_ASSIGNMENT_WORD, &exec_var},
{MATH, &exec_math},
{SUBSHELL, &exec_leaf}, {SUBSHELL, &exec_leaf},
{TK_LBRACE, &exec_leaf}, {TK_LBRACE, &exec_leaf},
{TK_BANG, &exec_bang}, {TK_BANG, &exec_bang},

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 03:38:36 by wescande #+# #+# */ /* Created: 2017/03/08 03:38:36 by wescande #+# #+# */
/* Updated: 2017/03/14 00:49:02 by ariard ### ########.fr */ /* Updated: 2017/03/15 01:24:26 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -31,6 +31,6 @@ void *node_copy(void *data)
new->data.cmd.token = ft_ld_copy(old->data.cmd.token, &tab_esc_copy); new->data.cmd.token = ft_ld_copy(old->data.cmd.token, &tab_esc_copy);
} }
if (old->type == TK_FOR || old->type == TK_PAREN_OPEN || old->type == TK_CASE) if (old->type == TK_FOR || old->type == TK_PAREN_OPEN || old->type == TK_CASE)
new->data.cmd.wordlist = ft_ld_copy(old->data.cmd.token, &tab_esc_copy); new->data.cmd.token = ft_ld_copy(old->data.cmd.token, &tab_esc_copy);
return (new); return (new);
} }

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 02:26:31 by wescande #+# #+# */ /* Created: 2017/03/08 02:26:31 by wescande #+# #+# */
/* Updated: 2017/03/13 22:31:32 by jhalford ### ########.fr */ /* Updated: 2017/03/15 02:04:14 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,7 +14,6 @@
int pfree_cond(t_process *p) int pfree_cond(t_process *p)
{ {
btree_del(&p->data.d_while.condition, &ast_free);
btree_del(&p->data.d_while.content, &ast_free); btree_del(&p->data.d_while.content, &ast_free);
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 02:37:04 by wescande #+# #+# */ /* Created: 2017/03/08 02:37:04 by wescande #+# #+# */
/* Updated: 2017/03/13 22:31:32 by jhalford ### ########.fr */ /* Updated: 2017/03/15 01:05:43 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,7 +14,7 @@
int pfree_list(t_process *p) int pfree_list(t_process *p)
{ {
ft_ld_del(&p->data.d_for.list_word, &ft_tabdel); ft_ld_del(&p->data.d_for.token, &ft_tabdel);
btree_del(&p->data.d_for.content, &ast_free); btree_del(&p->data.d_for.content, &ast_free);
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */ /* Created: 2017/03/07 15:48:24 by jhalford #+# #+# */
/* Updated: 2017/03/13 23:35:37 by jhalford ### ########.fr */ /* Updated: 2017/03/14 22:34:53 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,43 +6,21 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 19:02:23 by wescande #+# #+# */ /* Created: 2017/03/07 19:02:23 by wescande #+# #+# */
/* Updated: 2017/03/13 20:28:57 by jhalford ### ########.fr */ /* Updated: 2017/03/15 01:10:32 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
/*
int exec_case(t_btree **ast)
{
t_astnode *node;
char **av;
t_exec *exec;
(void)ast;
exec = &data_singleton()->exec;
exec->attrs &= ~EXEC_CASE_BRANCH;
node = (*ast)->item;
av = token_to_argv(node->data.cmd.wordlist, 1);
exec->case_pattern = av;
return (0);
}
*/
static int do_case(t_process *p) static int do_case(t_process *p)
{ {
t_exec *exec; t_exec *exec;
DG("exec case");
exec = &data_singleton()->exec; exec = &data_singleton()->exec;
exec->attrs &= ~EXEC_CASE_BRANCH; exec->attrs &= ~EXEC_CASE_BRANCH;
exec->case_pattern = token_to_argv(p->data.d_case.list_word, 1); exec->case_pattern = token_to_argv(p->data.d_case.token, 1);
/* ft_exec(&p->data.d_if.condition); ft_exec(&p->data.d_if.content);
if (!(ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0")))
{
exec->attrs |= EXEC_IF_BRANCH;
ft_exec(&p->data.d_if.content);
}
return (ft_atoi(ft_getenv(data_singleton()->env, "?")));*/
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */ /* Created: 2017/03/07 14:53:31 by jhalford #+# #+# */
/* Updated: 2017/03/14 21:48:36 by jhalford ### ########.fr */ /* Updated: 2017/03/14 23:30:54 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/15 00:49:20 by wescande #+# #+# */ /* Created: 2017/03/15 00:49:20 by wescande #+# #+# */
/* Updated: 2017/03/15 01:46:48 by wescande ### ########.fr */ /* Updated: 2017/03/15 03:51:52 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,10 +19,11 @@ static int do_for(t_process *p)
char **av; char **av;
char *var; char *var;
temp = p->data.d_for.list_word; temp = p->data.d_for.token;
var = ((char **)temp->content)[0]; var = ((char **)temp->content)[0];
if (!word_is_assignment(temp->content)) if (!word_is_assignment(temp->content))
return (error_badidentifier(var)); return (error_badidentifier(var));
DG();
temp = temp->next; temp = temp->next;
while (temp) while (temp)
{ {
@ -30,8 +31,8 @@ static int do_for(t_process *p)
av = token_to_argv(temp, 1); av = token_to_argv(temp, 1);
while (av[++i]) while (av[++i])
{ {
builtin_setenv("setenv", (char*[]){var, av[i], 0}, builtin_setenv("setenv", (char*[]){"local" ,var, av[i], 0},
data_singleton()->local_var); NULL);
ft_exec(&p->data.d_for.content); ft_exec(&p->data.d_for.content);
} }
temp = temp->next; temp = temp->next;
@ -64,33 +65,3 @@ int plaunch_for(t_process *p)
do_for(p); do_for(p);
return (0); return (0);
} }
/*
int exec_for(t_btree **ast)
{
t_astnode *node;
t_ld *temp;
char **av;
char *var;
int i;
node = (*ast)->item;
temp = node->data.cmd.wordlist;
var = ((char **)(temp->content))[0];
if (ft_isdigit(var[0]))
return (error_badidentifier(var));
temp = temp->next;
while (temp)
{
i = 0;
av = token_to_argv(temp, 1);
while (av[i])
{
builtin_setenv("setenv", (char*[]){var, av[i], 0},
data_singleton()->local_var);
ft_exec(&(*ast)->right);
i++;
}
temp = temp->next;
}
return (0);
}*/

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 17:26:53 by wescande #+# #+# */ /* Created: 2017/03/07 17:26:53 by wescande #+# #+# */
/* Updated: 2017/03/13 20:28:57 by jhalford ### ########.fr */ /* Updated: 2017/03/15 02:04:23 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,12 +18,7 @@ static int do_if(t_process *p)
exec = &data_singleton()->exec; exec = &data_singleton()->exec;
exec->attrs &= ~EXEC_IF_BRANCH; exec->attrs &= ~EXEC_IF_BRANCH;
ft_exec(&p->data.d_if.condition); ft_exec(&p->data.d_if.content);
if (!(ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0")))
{
exec->attrs |= EXEC_IF_BRANCH;
ft_exec(&p->data.d_if.content);
}
return (ft_atoi(ft_getenv(data_singleton()->env, "?"))); return (ft_atoi(ft_getenv(data_singleton()->env, "?")));
} }

View file

@ -6,29 +6,12 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 17:20:53 by wescande #+# #+# */ /* Created: 2017/03/07 17:20:53 by wescande #+# #+# */
/* Updated: 2017/03/13 20:28:53 by jhalford ### ########.fr */ /* Updated: 2017/03/15 00:55:31 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
/*
int exec_while(t_btree **ast)
{
int ret;
DG("exec while condition");
ft_exec(&(*ast)->left);
DG("ret :[%s]", ft_getenv(data_singleton()->env, "?"));
while (!(ft_strcmp(ft_getenv(data_singleton()->env, "?"), "0")))
{
DG("in the while");
ft_exec(&(*ast)->right);
ret = ft_atoi(ft_getenv(data_singleton()->env, "?"));
ft_exec(&(*ast)->left);
}
exit(ret);
return (0);
}
*/
static int do_while(t_process *p) static int do_while(t_process *p)
{ {
int ret; int ret;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */ /* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
/* Updated: 2017/03/13 23:10:42 by jhalford ### ########.fr */ /* Updated: 2017/03/15 01:52:43 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */ /* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
/* Updated: 2017/03/13 22:40:00 by jhalford ### ########.fr */ /* Updated: 2017/03/15 00:57:31 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 20:36:04 by wescande #+# #+# */ /* Created: 2017/03/07 20:36:04 by wescande #+# #+# */
/* Updated: 2017/03/13 20:31:21 by jhalford ### ########.fr */ /* Updated: 2017/03/15 01:46:29 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,7 +14,8 @@
int pset_case(t_process *p, t_btree *ast) int pset_case(t_process *p, t_btree *ast)
{ {
p->data.d_case.list_word = ft_ld_copy(((t_astnode *)ast->item)->data.cmd.wordlist, tab_esc_copy); DG("set case");
p->data.d_case.token = ft_ld_copy(((t_astnode *)ast->item)->data.cmd.token, tab_esc_copy);
p->data.d_case.content = btree_map(ast->right, &node_copy); p->data.d_case.content = btree_map(ast->right, &node_copy);
p->type = PROCESS_CASE; p->type = PROCESS_CASE;
return (0); return (0);

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:06:05 by wescande #+# #+# */ /* Created: 2017/03/07 15:06:05 by wescande #+# #+# */
/* Updated: 2017/03/13 22:52:43 by jhalford ### ########.fr */ /* Updated: 2017/03/14 21:25:01 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 19:38:05 by wescande #+# #+# */ /* Created: 2017/03/07 19:38:05 by wescande #+# #+# */
/* Updated: 2017/03/13 20:31:21 by jhalford ### ########.fr */ /* Updated: 2017/03/15 01:57:17 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,7 +14,7 @@
int pset_for(t_process *p, t_btree *ast) int pset_for(t_process *p, t_btree *ast)
{ {
p->data.d_for.list_word = ft_ld_copy(((t_astnode *)ast->item)->data.cmd.wordlist, tab_esc_copy); p->data.d_for.token = ft_ld_copy(((t_astnode *)ast->item)->data.cmd.token, tab_esc_copy);
p->data.d_for.content = btree_map(ast->right, &node_copy); p->data.d_for.content = btree_map(ast->right, &node_copy);
p->type = PROCESS_FOR; p->type = PROCESS_FOR;
return (0); return (0);

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 19:19:50 by wescande #+# #+# */ /* Created: 2017/03/07 19:19:50 by wescande #+# #+# */
/* Updated: 2017/03/13 20:31:21 by jhalford ### ########.fr */ /* Updated: 2017/03/15 02:03:19 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,7 +14,6 @@
int pset_if(t_process *p, t_btree *ast) int pset_if(t_process *p, t_btree *ast)
{ {
p->data.d_if.condition = btree_map(ast->left, &node_copy);
p->data.d_if.content = btree_map(ast->right, &node_copy); p->data.d_if.content = btree_map(ast->right, &node_copy);
p->type = PROCESS_IF; p->type = PROCESS_IF;
return (0); return (0);

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 15:55:53 by wescande #+# #+# */ /* Created: 2017/03/07 15:55:53 by wescande #+# #+# */
/* Updated: 2017/03/13 17:23:53 by jhalford ### ########.fr */ /* Updated: 2017/03/14 22:39:25 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */ /* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */
/* Updated: 2017/03/13 14:53:33 by jhalford ### ########.fr */ /* Updated: 2017/03/14 23:43:00 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */ /* Created: 2016/12/15 11:49:05 by jhalford #+# #+# */
/* Updated: 2017/03/13 17:36:32 by jhalford ### ########.fr */ /* Updated: 2017/03/14 23:43:12 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -24,7 +24,8 @@ int job_wait(int id)
DG("job wait id=[%i], pgid=[%i]", id, j->pgid); DG("job wait id=[%i], pgid=[%i]", id, j->pgid);
do do
{ {
if ((pid = waitpid(-j->pgid, &status, WUNTRACED)) == -1) if ((pid = waitpid(-j->pgid, &status, WUNTRACED)) == -1
&& errno != ECHILD)
ft_dprintf(2, "{red}%s: waitpid error errno=%i{eoc}\n", SHELL_NAME, errno); ft_dprintf(2, "{red}%s: waitpid error errno=%i{eoc}\n", SHELL_NAME, errno);
DG("waitpid->[%d]", pid); DG("waitpid->[%d]", pid);
} }

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
/* Updated: 2017/03/14 22:41:51 by wescande ### ########.fr */ /* Updated: 2017/03/15 03:52:15 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */ /* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */
/* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */ /* Updated: 2017/03/14 22:11:26 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,10 +19,6 @@ char *ft_putast(void *nodein)
if (node->type == TK_BANG) if (node->type == TK_BANG)
return ("TK_BANG"); return ("TK_BANG");
if (node->type == MATH)
return ("MATH");
if (node->type == MATH_PLUS)
return ("MATH_PLUS");
if (node->type == TK_DSEMI) if (node->type == TK_DSEMI)
return ("TK_DSEMI"); return ("TK_DSEMI");
if (node->type == WORDLIST) if (node->type == WORDLIST)

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/03/14 23:08:20 by wescande ### ########.fr */ /* Updated: 2017/03/15 03:52:32 by wescande ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -72,7 +72,7 @@ int handle_instruction(int fd)
} }
btree_print(STDBUG, ast, &ft_putast); btree_print(STDBUG, ast, &ft_putast);
if (ft_exec(&ast)) if (ft_exec(&ast))
return (1); return (2);
instruction_free(&token, &parser, &ast); instruction_free(&token, &parser, &ast);
if (SH_IS_INTERACTIVE(data_singleton()->opts) && *lexer.str) if (SH_IS_INTERACTIVE(data_singleton()->opts) && *lexer.str)
ft_add_str_in_history(lexer.str); ft_add_str_in_history(lexer.str);
@ -97,7 +97,6 @@ int get_input_fd(char **av)
pipe(fds); pipe(fds);
dup2_close(fds[PIPE_READ], 10); dup2_close(fds[PIPE_READ], 10);
fd = 10; fd = 10;
//fd = fds[PIPE_READ];
file = *cliopts_getdata(av); file = *cliopts_getdata(av);
write(fds[PIPE_WRITE], file, ft_strlen(file)); write(fds[PIPE_WRITE], file, ft_strlen(file));
close(fds[PIPE_WRITE]); close(fds[PIPE_WRITE]);

View file

@ -6,13 +6,13 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
/* Updated: 2017/03/14 21:50:11 by jhalford ### ########.fr */ /* Updated: 2017/03/14 23:25:40 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
static t_cliopts shell_opts[] = static t_cliopts g_opts[] =
{ {
{'c', NULL, SH_OPTS_LC, SH_OPTS_JOBC | SH_INTERACTIVE, NULL}, {'c', NULL, SH_OPTS_LC, SH_OPTS_JOBC | SH_INTERACTIVE, NULL},
{-1, "no-jobcontrol", 0, SH_OPTS_JOBC, NULL}, {-1, "no-jobcontrol", 0, SH_OPTS_JOBC, NULL},
@ -40,7 +40,7 @@ static int interactive_settings(void)
if (setpgid(*shell_pgid, *shell_pgid)) if (setpgid(*shell_pgid, *shell_pgid))
{ {
ft_dprintf(2, "Couldnt put the shell in it's own process group"); ft_dprintf(2, "Couldnt put the shell in it's own process group");
exit (1); exit(1);
} }
tcsetpgrp(STDIN, *shell_pgid); tcsetpgrp(STDIN, *shell_pgid);
tcgetattr(STDIN, &data->jobc.shell_tmodes); tcgetattr(STDIN, &data->jobc.shell_tmodes);
@ -61,7 +61,7 @@ int shell_init(int ac, char **av)
} }
else else
DG("non interactive"); DG("non interactive");
if (cliopts_get(av, shell_opts, data)) if (cliopts_get(av, g_opts, data))
return (ft_perror()); return (ft_perror());
if (SH_IS_INTERACTIVE(data->opts)) if (SH_IS_INTERACTIVE(data->opts))
interactive_settings(); interactive_settings();

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/04 20:42:13 by ariard #+# #+# */ /* Created: 2017/03/04 20:42:13 by ariard #+# #+# */
/* Updated: 2017/03/13 22:38:44 by ariard ### ########.fr */ /* Updated: 2017/03/15 01:09:23 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -25,24 +25,8 @@ int iscase(t_btree **ast, t_list **lst)
|| node->type == TK_AMP || node->type == TK_PIPE) || node->type == TK_AMP || node->type == TK_PIPE)
&& iscase(&(*ast)->right, lst) == 1) && iscase(&(*ast)->right, lst) == 1)
return (1); return (1);
if (node->type == TK_CASE)
return (1);
}
return (0);
}
int iscase_pattern(t_btree **ast, t_list **lst)
{
t_astnode *node;
t_token *token;
node = NULL;
token = (*lst)->content;
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)
&& token->type == TK_WORD && node->pattern == 0) && node->pattern == 1 && node->full == 0)
return (1); return (1);
} }
return (0); return (0);
@ -58,7 +42,7 @@ int iscase_branch(t_btree **ast, t_list **lst)
if (*ast) if (*ast)
{ {
node = (*ast)->item; node = (*ast)->item;
if ((node->type == TK_PAREN_OPEN || node->type == TK_CASE) if ((node->type == TK_PAREN_OPEN)
&& node->nest == 0 && token->type == TK_PAREN_OPEN) && node->nest == 0 && token->type == TK_PAREN_OPEN)
return (1); return (1);
} }
@ -81,22 +65,10 @@ int add_case_cmd(t_btree **ast, t_list **lst)
else if (token->type == TK_DSEMI && node->type == TK_PAREN_OPEN else if (token->type == TK_DSEMI && node->type == TK_PAREN_OPEN
&& node->nest == 0) && node->nest == 0)
return ((node->full = 1)); return ((node->full = 1));
else if ((token->type == TK_ESAC || token->type == TK_PAREN_CLOSE) else if ((token->type == TK_ESAC)
&& node->nest == 0) && node->nest == 0)
return ((node->full = 1));
else if (token->type == TK_PAREN_CLOSE)
return (0); return (0);
return (add_cmd(&(*ast)->right, lst)); return (add_cmd(&(*ast)->right, lst));
} }
int add_pattern(t_btree **ast, t_list **lst)
{
t_astnode *node;
t_token *token;
token = (*lst)->content;
node = (*ast)->item;
DG("node type is %s", read_state(node->type));
ft_ld_pushback(&node->data.cmd.wordlist,
gen_tab(token->data, token->esc, token->esc2, 1));
node->pattern = 1;
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 20:49:15 by ariard #+# #+# */ /* Created: 2017/02/15 20:49:15 by ariard #+# #+# */
/* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */ /* Updated: 2017/03/15 02:12:28 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,22 +15,18 @@
t_distrostree g_distrostree[] = t_distrostree g_distrostree[] =
{ {
{&superflous_token, &add_null}, {&superflous_token, &add_null},
{&isdir_sep, &add_redir_type},
{&isdir_word, &add_redir_word},
{&isloop_condition, &add_loop_condition},
{&isloop, &add_loop_cmd}, {&isloop, &add_loop_cmd},
{&iscondition_branch, &add_branch}, {&iscondition_branch, &add_branch},
{&iscondition, &add_condition_cmd}, {&iscondition, &add_condition_cmd},
{&iscase_pattern, &add_pattern},
{&iscase, &add_case_cmd}, {&iscase, &add_case_cmd},
{&iscase_branch, &add_branch}, {&iscase_branch, &add_branch},
{&ismath, &add_null},
{&ismath_expr, &add_pattern},
{&issubshell, &add_subshell_cmd}, {&issubshell, &add_subshell_cmd},
{&isfunc_name, &add_null}, {&isfunc_name, &add_null},
{&isfunc, &add_func_cmd}, {&isfunc, &add_func_cmd},
{&isionumber, &add_ionumber}, {&isionumber, &add_ionumber},
{&isbang, &add_bang}, {&isbang, &add_bang},
{&isdir_sep, &add_redir_type},
{&isdir_word, &add_redir_word},
{&isnull, &add_null}, {&isnull, &add_null},
}; };
@ -42,7 +38,7 @@ int superflous_token(t_btree **ast, t_list **lst)
if (*lst) if (*lst)
{ {
token = (*lst)->content; token = (*lst)->content;
if (token->type == TK_IN || token->type == TK_DSEMI) if (token->type == TK_IN)
return (1); return (1);
} }
return (0); return (0);
@ -51,15 +47,19 @@ int superflous_token(t_btree **ast, t_list **lst)
static int no_del_token(t_btree **ast, t_list **lst) static int no_del_token(t_btree **ast, t_list **lst)
{ {
t_astnode *node; t_astnode *node;
t_token *token;
(void)lst;
node = NULL; node = NULL;
token = (*lst)->content;
if (*ast) if (*ast)
{ {
node = (*ast)->item; node = (*ast)->item;
if (token->type == TK_WORD && (node->type == TK_CASE
|| node->type == TK_PAREN_OPEN))
return (0);
if (node->type != TK_DO && node->type != TK_THEN if (node->type != TK_DO && node->type != TK_THEN
&& node->type != CMD && node->type != REDIR && node->type != CMD && node->type != REDIR
&& node->type != TK_ASSIGNMENT_WORD) && node->type != TK_ASSIGNMENT_WORD && node->type != TK_FOR)
return (1); return (1);
} }
return (0); return (0);
@ -72,7 +72,7 @@ int add_cmd(t_btree **ast, t_list **lst)
int i; int i;
i = -1; i = -1;
while (++i < 18) while (++i < 14)
{ {
if (g_distrostree[i].test(ast, lst) == 1) if (g_distrostree[i].test(ast, lst) == 1)
{ {
@ -88,15 +88,18 @@ int add_cmd(t_btree **ast, t_list **lst)
node = (*ast)->item; node = (*ast)->item;
if (token->type == TK_IF) if (token->type == TK_IF)
add_if(ast, lst); add_if(ast, lst);
else if (token->type != TK_WORD) else if (token->type != TK_WORD && token->type != TK_NAME)
{
DG("type is %s", read_state(token->type));
node->type = token->type; node->type = token->type;
} else if (node->type != TK_CASE && node->type != TK_PAREN_OPEN && node->type != TK_FOR)
else
node->type = CMD; node->type = CMD;
if (token->type == TK_WORD || token->type == TK_ASSIGNMENT_WORD) if (token->type == TK_WORD || token->type == TK_ASSIGNMENT_WORD || token->type == TK_NAME)
{
DG("type is %s", read_state(node->type));
ft_ld_pushback(&node->data.cmd.token, ft_ld_pushback(&node->data.cmd.token,
gen_tab(token->data, token->esc, token->esc2, 1)); gen_tab(token->data, token->esc, token->esc2, 1));
}
if ((token->type == TK_WORD || token->type == TK_NAME)
&& (node->type == TK_CASE || node->type == TK_PAREN_OPEN))
node->pattern = 1;
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/24 23:43:07 by ariard #+# #+# */ /* Created: 2017/02/24 23:43:07 by ariard #+# #+# */
/* Updated: 2017/03/13 19:27:58 by ariard ### ########.fr */ /* Updated: 2017/03/15 00:26:57 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,33 +6,13 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/17 22:17:14 by ariard #+# #+# */ /* Created: 2017/02/17 22:17:14 by ariard #+# #+# */
/* Updated: 2017/03/13 16:12:35 by ariard ### ########.fr */ /* Updated: 2017/03/15 01:59:52 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
int isloop(t_btree **ast, t_list **lst) int isloop(t_btree **ast, t_list **lst)
{
t_astnode *node;
(void)lst;
node = NULL;
if (*ast)
{
node = (*ast)->item;
if ((node->type == TK_NEWLINE || node->type == TK_SEMI
|| node->type == TK_AMP || node->type == TK_PIPE)
&& isloop(&(*ast)->right, lst) == 1)
return (1);
if ((node->type == TK_WHILE || node->type == TK_UNTIL
|| node->type == TK_FOR) && node->full == 0)
return (1);
}
return (0);
}
int isloop_condition(t_btree **ast, t_list **lst)
{ {
t_astnode *node; t_astnode *node;
t_token *token; t_token *token;
@ -42,8 +22,18 @@ int isloop_condition(t_btree **ast, t_list **lst)
if (*ast) if (*ast)
{ {
node = (*ast)->item; node = (*ast)->item;
if (node->type == TK_FOR && (token->type == TK_NEWLINE
|| token->type == TK_SEMI) && node->pattern == 0)
return (1);
if (node->type == TK_FOR && (token->type == TK_WORD if (node->type == TK_FOR && (token->type == TK_WORD
|| token->type == TK_NAME) && node->pattern == 0) || token->type == TK_NAME) && node->pattern == 0)
return (0);
if ((node->type == TK_NEWLINE || node->type == TK_SEMI
|| node->type == TK_AMP || node->type == TK_PIPE)
&& isloop(&(*ast)->right, lst) == 1)
return (1);
if ((node->type == TK_WHILE || node->type == TK_UNTIL
|| node->type == TK_FOR) && node->full == 0)
return (1); return (1);
} }
return (0); return (0);
@ -79,21 +69,18 @@ int add_loop_cmd(t_btree **ast, t_list **lst)
int add_loop_sep(t_btree **ast, t_list **lst) int add_loop_sep(t_btree **ast, t_list **lst)
{ {
t_astnode *node;
node = NULL;
if (*ast)
{
node = (*ast)->item;
if (node->type == TK_FOR && node->pattern == 0)
return (0);
}
if (!(*ast)->right) if (!(*ast)->right)
return (add_sep(&(*ast)->left, lst)); return (add_sep(&(*ast)->left, lst));
else else
return (add_sep(&(*ast)->right, lst)); return (add_sep(&(*ast)->right, lst));
return (0); return (0);
} }
int add_loop_condition(t_btree **ast, t_list **lst)
{
t_astnode *node;
t_token *token;
token = (*lst)->content;
node = (*ast)->item;
ft_ld_pushback(&node->data.cmd.wordlist,
gen_tab(token->data, token->esc, token->esc2, 1));
return (0);
}

View file

@ -1,50 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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)
{
t_astnode *node;
t_token *token;
node = NULL;
token = (*lst)->content;
if (*ast)
{
node = (*ast)->item;
if (node->type == SUBSHELL && token->type == SUBSHELL)
{
node->type = MATH;
return (1);
}
if (node->type == MATH && token->type == TK_PAREN_CLOSE)
return (1);
}
return (0);
}
int ismath_expr(t_btree **ast, t_list **lst)
{
t_astnode *node;
t_token *token;
node = NULL;
token = (*lst)->content;
if (*ast)
{
node = (*ast)->item;
if (node->type == MATH && token->type == TK_WORD)
return (1);
}
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/17 16:39:05 by ariard #+# #+# */ /* Created: 2017/02/17 16:39:05 by ariard #+# #+# */
/* Updated: 2017/03/13 22:39:30 by jhalford ### ########.fr */ /* Updated: 2017/03/15 02:09:54 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 19:12:07 by ariard #+# #+# */ /* Created: 2017/02/15 19:12:07 by ariard #+# #+# */
/* Updated: 2017/03/13 16:25:31 by ariard ### ########.fr */ /* Updated: 2017/03/15 01:41:06 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 15:58:38 by ariard #+# #+# */ /* Created: 2017/03/11 15:58:38 by ariard #+# #+# */
/* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */ /* Updated: 2017/03/14 22:02:07 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -22,14 +22,12 @@ t_aggrematch g_aggrematch[] =
{TK_WORD, TK_PIPE, PATTERN, 0}, {TK_WORD, TK_PIPE, PATTERN, 0},
{TK_WORD, TK_IN, FOR_WORDLIST, TK_IN}, {TK_WORD, TK_IN, FOR_WORDLIST, TK_IN},
{TK_WORD, FOR_WORDLIST, FOR_WORDLIST, FOR_WORDLIST}, {TK_WORD, FOR_WORDLIST, FOR_WORDLIST, FOR_WORDLIST},
{TK_WORD, MATH, MATH, MATH},
{TK_SEMI, FOR_WORDLIST, SEQUENTIAL_SEP, 0}, {TK_SEMI, FOR_WORDLIST, SEQUENTIAL_SEP, 0},
{TK_DSEMI, CMD_SUPERIOR, PIPE_SEQUENCE, CMD_SUPERIOR}, {TK_DSEMI, CMD_SUPERIOR, PIPE_SEQUENCE, CMD_SUPERIOR},
{TK_DSEMI, PIPE_SEMI_SEQUENCE, PIPE_SEQUENCE, PIPE_SEMI_SEQUENCE}, {TK_DSEMI, PIPE_SEMI_SEQUENCE, PIPE_SEQUENCE, PIPE_SEMI_SEQUENCE},
{TK_DSEMI, PIPE_CLOSE_SEQUENCE, PIPE_SEQUENCE, PIPE_CLOSE_SEQUENCE}, {TK_DSEMI, PIPE_CLOSE_SEQUENCE, PIPE_SEQUENCE, PIPE_CLOSE_SEQUENCE},
{TK_PAREN_OPEN, TK_IN, PATTERN_CASE, 0}, {TK_PAREN_OPEN, TK_IN, PATTERN_CASE, 0},
{TK_PAREN_OPEN, CASE_LIST_NS, PATTERN_CASE, 0}, {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_PAREN_OPEN, CMD_SUPERIOR, OPEN_FUNC, 0},
{TK_ASSIGNMENT_WORD, CMD_PREFIX, CMD_PREFIX, 0}, {TK_ASSIGNMENT_WORD, CMD_PREFIX, CMD_PREFIX, 0},
{TK_PIPE, CMD_SUPERIOR, SEQUENCE, CMD_SUPERIOR}, {TK_PIPE, CMD_SUPERIOR, SEQUENCE, CMD_SUPERIOR},
@ -45,8 +43,6 @@ t_aggrematch g_aggrematch[] =
{TK_ESAC, TK_IN, CASE_CLAUSE, TK_CASE}, {TK_ESAC, TK_IN, CASE_CLAUSE, TK_CASE},
{TK_ESAC, CASE_LIST_NS, CASE_CLAUSE, TK_CASE}, {TK_ESAC, CASE_LIST_NS, CASE_CLAUSE, TK_CASE},
{TK_RBRACE, COMPOUND_LIST, BRACE_GROUP, TK_LBRACE}, {TK_RBRACE, COMPOUND_LIST, BRACE_GROUP, TK_LBRACE},
{TK_PAREN_CLOSE, MATH, MATH_PLUS, MATH},
{TK_PAREN_CLOSE, MATH_PLUS, MATH_SUP, MATH_PLUS},
{TK_PAREN_CLOSE, COMPOUND_LIST, SUBSHELL, TK_PAREN_OPEN}, {TK_PAREN_CLOSE, COMPOUND_LIST, SUBSHELL, TK_PAREN_OPEN},
{TK_PAREN_CLOSE, CMD_SUPERIOR, SUBSHELL, TK_PAREN_OPEN}, {TK_PAREN_CLOSE, CMD_SUPERIOR, SUBSHELL, TK_PAREN_OPEN},
{TK_PAREN_CLOSE, PIPE_SEMI_SEQUENCE, SUBSHELL, TK_PAREN_OPEN}, {TK_PAREN_CLOSE, PIPE_SEMI_SEQUENCE, SUBSHELL, TK_PAREN_OPEN},
@ -65,19 +61,16 @@ t_aggrematch g_aggrematch[] =
{TK_OR_IF, PIPE_SEMI_SEQUENCE, AND_OR_MINOR, PIPE_SEMI_SEQUENCE}, {TK_OR_IF, PIPE_SEMI_SEQUENCE, AND_OR_MINOR, PIPE_SEMI_SEQUENCE},
{TK_OR_IF, CMD_SUPERIOR, AND_OR_MINOR, CMD_SUPERIOR}, {TK_OR_IF, CMD_SUPERIOR, AND_OR_MINOR, CMD_SUPERIOR},
{TK_OR_IF, PIPE_CLOSE_SEQUENCE, AND_OR_MINOR, PIPE_CLOSE_SEQUENCE}, {TK_OR_IF, PIPE_CLOSE_SEQUENCE, AND_OR_MINOR, PIPE_CLOSE_SEQUENCE},
{SEPARATOR_OP, MATH_SUP, CMD_SUPERIOR, MATH_SUP},
{SEPARATOR_OP, CMD_SUPERIOR, SEPARATOR, 0}, {SEPARATOR_OP, CMD_SUPERIOR, SEPARATOR, 0},
{SEPARATOR_OP, COMPOUND_LIST, SEPARATOR, 0}, {SEPARATOR_OP, COMPOUND_LIST, SEPARATOR, 0},
{SEPARATOR_OP, CASE_LIST_NS, SEPARATOR, 0}, {SEPARATOR_OP, CASE_LIST_NS, SEPARATOR, 0},
{SEPARATOR_OP, PIPE_SEMI_SEQUENCE, SEPARATOR, 0}, {SEPARATOR_OP, PIPE_SEMI_SEQUENCE, SEPARATOR, 0},
{SEPARATOR_OP, PIPE_CLOSE_SEQUENCE, SEPARATOR, 0}, {SEPARATOR_OP, PIPE_CLOSE_SEQUENCE, SEPARATOR, 0},
{SEPARATOR, MATH_SUP, CMD_SUPERIOR, MATH_SUP},
{SEPARATOR, CMD_SUPERIOR, END_COMMAND, CMD_SUPERIOR}, {SEPARATOR, CMD_SUPERIOR, END_COMMAND, CMD_SUPERIOR},
{SEPARATOR, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS}, {SEPARATOR, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS},
{SEPARATOR, COMPOUND_LIST, COMPOUND_LIST, COMPOUND_LIST}, {SEPARATOR, COMPOUND_LIST, COMPOUND_LIST, COMPOUND_LIST},
{SEPARATOR, PIPE_SEMI_SEQUENCE, PIPE_SEQUENCE, PIPE_SEMI_SEQUENCE}, {SEPARATOR, PIPE_SEMI_SEQUENCE, PIPE_SEQUENCE, PIPE_SEMI_SEQUENCE},
{SEPARATOR, PIPE_CLOSE_SEQUENCE, PIPE_SEQUENCE, PIPE_CLOSE_SEQUENCE}, {SEPARATOR, PIPE_CLOSE_SEQUENCE, PIPE_SEQUENCE, PIPE_CLOSE_SEQUENCE},
{LINEBREAK, MATH_SUP, CMD_SUPERIOR, MATH_SUP},
{LINEBREAK, SEPARATOR_OP, SEPARATOR, SEPARATOR_OP}, {LINEBREAK, SEPARATOR_OP, SEPARATOR, SEPARATOR_OP},
{LINEBREAK, TK_SEMI, SEQUENTIAL_SEP, TK_SEMI}, {LINEBREAK, TK_SEMI, SEQUENTIAL_SEP, TK_SEMI},
{LINEBREAK, TK_PAREN_CLOSE, FUNC, FNAME}, {LINEBREAK, TK_PAREN_CLOSE, FUNC, FNAME},
@ -87,7 +80,6 @@ t_aggrematch g_aggrematch[] =
{LINEBREAK, PIPE_CLOSE_SEQUENCE, PIPE_SEQUENCE, PIPE_CLOSE_SEQUENCE}, {LINEBREAK, PIPE_CLOSE_SEQUENCE, PIPE_SEQUENCE, PIPE_CLOSE_SEQUENCE},
{LINEBREAK, COMPOUND_LIST, COMPOUND_LIST, COMPOUND_LIST}, {LINEBREAK, COMPOUND_LIST, COMPOUND_LIST, COMPOUND_LIST},
{LINEBREAK, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS}, {LINEBREAK, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS},
{NEWLINE_LIST, MATH_SUP, CMD_SUPERIOR, MATH_SUP},
{NEWLINE_LIST, CMD_NAME, CMD_SUPERIOR, CMD_NAME}, {NEWLINE_LIST, CMD_NAME, CMD_SUPERIOR, CMD_NAME},
{NEWLINE_LIST, SEQUENTIAL_SEP, SEQUENTIAL_SEP, SEQUENTIAL_SEP}, {NEWLINE_LIST, SEQUENTIAL_SEP, SEQUENTIAL_SEP, SEQUENTIAL_SEP},
{NEWLINE_LIST, TK_DO, TK_DO, TK_DO}, {NEWLINE_LIST, TK_DO, TK_DO, TK_DO},

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 16:11:21 by ariard #+# #+# */ /* Created: 2017/03/11 16:11:21 by ariard #+# #+# */
/* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */ /* Updated: 2017/03/14 22:01:19 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -25,7 +25,6 @@ t_stackmatch g_stackmatch[] =
{TK_WORD, COMPLETE_COMMANDS}, {TK_WORD, COMPLETE_COMMANDS},
{TK_WORD, TK_IN}, {TK_WORD, TK_IN},
{TK_WORD, FOR_WORDLIST}, {TK_WORD, FOR_WORDLIST},
{TK_WORD, MATH},
{TK_ASSIGNMENT_WORD, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, CMD_PREFIX},
{TK_IO_NUMBER, REDIRECT_LIST}, {TK_IO_NUMBER, REDIRECT_LIST},
{TK_IO_NUMBER, CMD_SUFFIX}, {TK_IO_NUMBER, CMD_SUFFIX},
@ -501,14 +500,12 @@ t_stackmatch g_stackmatch[] =
{END_COMMAND, CASE_LIST_NS}, {END_COMMAND, CASE_LIST_NS},
{END_COMMAND, COMPLETE_CONDITION}, {END_COMMAND, COMPLETE_CONDITION},
{END_COMMAND, CONDITION}, {END_COMMAND, CONDITION},
{SEPARATOR, MATH_SUP},
{SEPARATOR, CMD_SUPERIOR}, {SEPARATOR, CMD_SUPERIOR},
{SEPARATOR, TERM}, {SEPARATOR, TERM},
{SEPARATOR, COMPOUND_LIST}, {SEPARATOR, COMPOUND_LIST},
{SEPARATOR, CASE_LIST_NS}, {SEPARATOR, CASE_LIST_NS},
{SEPARATOR, PIPE_SEMI_SEQUENCE}, {SEPARATOR, PIPE_SEMI_SEQUENCE},
{SEPARATOR, PIPE_CLOSE_SEQUENCE}, {SEPARATOR, PIPE_CLOSE_SEQUENCE},
{SEPARATOR_OP, MATH_SUP},
{SEPARATOR_OP, CMD_SUPERIOR}, {SEPARATOR_OP, CMD_SUPERIOR},
{SEPARATOR_OP, LIST}, {SEPARATOR_OP, LIST},
{SEPARATOR_OP, TERM}, {SEPARATOR_OP, TERM},
@ -516,7 +513,6 @@ t_stackmatch g_stackmatch[] =
{SEPARATOR_OP, COMPOUND_LIST}, {SEPARATOR_OP, COMPOUND_LIST},
{SEPARATOR_OP, PIPE_SEMI_SEQUENCE}, {SEPARATOR_OP, PIPE_SEMI_SEQUENCE},
{SEPARATOR_OP, PIPE_CLOSE_SEQUENCE}, {SEPARATOR_OP, PIPE_CLOSE_SEQUENCE},
{LINEBREAK, MATH_SUP},
{LINEBREAK, TK_SEMI}, {LINEBREAK, TK_SEMI},
{LINEBREAK, END_COMMAND}, {LINEBREAK, END_COMMAND},
{LINEBREAK, SEPARATOR_OP}, {LINEBREAK, SEPARATOR_OP},
@ -537,8 +533,6 @@ t_stackmatch g_stackmatch[] =
{LINEBREAK, PROGRAM}, {LINEBREAK, PROGRAM},
{LINEBREAK, TK_PAREN_OPEN}, {LINEBREAK, TK_PAREN_OPEN},
{LINEBREAK, TK_LBRACE}, {LINEBREAK, TK_LBRACE},
{TK_PAREN_CLOSE, MATH},
{TK_PAREN_CLOSE, MATH_PLUS},
{TK_PAREN_CLOSE, TK_SEMI}, {TK_PAREN_CLOSE, TK_SEMI},
{TK_PAREN_CLOSE, END_COMMAND}, {TK_PAREN_CLOSE, END_COMMAND},
{TK_PAREN_CLOSE, SEPARATOR_OP}, {TK_PAREN_CLOSE, SEPARATOR_OP},
@ -557,8 +551,6 @@ t_stackmatch g_stackmatch[] =
{TK_PAREN_CLOSE, COMPOUND_LIST}, {TK_PAREN_CLOSE, COMPOUND_LIST},
{TK_PAREN_CLOSE, FUNC_NAME}, {TK_PAREN_CLOSE, FUNC_NAME},
{TK_PAREN_CLOSE, OPEN_FUNC}, {TK_PAREN_CLOSE, OPEN_FUNC},
{TK_RBRACE, MATH},
{TK_RBRACE, MATH_PLUS},
{TK_RBRACE, TK_SEMI}, {TK_RBRACE, TK_SEMI},
{TK_RBRACE, END_COMMAND}, {TK_RBRACE, END_COMMAND},
{TK_RBRACE, SEPARATOR_OP}, {TK_RBRACE, SEPARATOR_OP},
@ -577,7 +569,6 @@ t_stackmatch g_stackmatch[] =
{TK_RBRACE, PATTERN}, {TK_RBRACE, PATTERN},
{TK_RBRACE, COMPOUND_LIST}, {TK_RBRACE, COMPOUND_LIST},
{TK_RBRACE, FUNC_NAME}, {TK_RBRACE, FUNC_NAME},
{NEWLINE_LIST, MATH_SUP},
{NEWLINE_LIST, TK_DO}, {NEWLINE_LIST, TK_DO},
{NEWLINE_LIST, CASE_LIST_NS}, {NEWLINE_LIST, CASE_LIST_NS},
{NEWLINE_LIST, TK_PAREN_CLOSE}, {NEWLINE_LIST, TK_PAREN_CLOSE},
@ -780,66 +771,6 @@ t_stackmatch g_stackmatch[] =
{CMD_SUPERIOR, AND_OR_MAJOR}, {CMD_SUPERIOR, AND_OR_MAJOR},
{CLOSE_FUNC, CMD_SUPERIOR}, {CLOSE_FUNC, CMD_SUPERIOR},
{CLOSE_FUNC, OPEN_FUNC}, {CLOSE_FUNC, OPEN_FUNC},
{MATH, LINEBREAK},
{MATH, NEWLINE_LIST},
{MATH, SEPARATOR},
{MATH, SEPARATOR_OP},
{MATH, TK_WHILE},
{MATH, TK_UNTIL},
{MATH, TK_DO},
{MATH, TK_IF},
{MATH, TK_ELIF},
{MATH, TK_THEN},
{MATH, TK_ELSE},
{MATH, COMPOUND_LIST},
{MATH, COMPLETE_CONDITION},
{MATH, CONDITION},
{MATH, TK_PAREN_OPEN},
{MATH, TK_LBRACE},
{MATH, SEQUENCE},
{MATH, COMPLETE_COMMANDS},
{MATH, AND_OR_MAJOR},
{MATH, TK_BANG},
{MATH_PLUS, LINEBREAK},
{MATH_PLUS, NEWLINE_LIST},
{MATH_PLUS, SEPARATOR},
{MATH_PLUS, SEPARATOR_OP},
{MATH_PLUS, TK_WHILE},
{MATH_PLUS, TK_UNTIL},
{MATH_PLUS, TK_DO},
{MATH_PLUS, TK_IF},
{MATH_PLUS, TK_ELIF},
{MATH_PLUS, TK_THEN},
{MATH_PLUS, TK_ELSE},
{MATH_PLUS, COMPOUND_LIST},
{MATH_PLUS, COMPLETE_CONDITION},
{MATH_PLUS, CONDITION},
{MATH_PLUS, TK_PAREN_OPEN},
{MATH_PLUS, TK_LBRACE},
{MATH_PLUS, SEQUENCE},
{MATH_PLUS, COMPLETE_COMMANDS},
{MATH_PLUS, AND_OR_MAJOR},
{MATH_PLUS, TK_BANG},
{MATH_SUP, LINEBREAK},
{MATH_SUP, NEWLINE_LIST},
{MATH_SUP, SEPARATOR},
{MATH_SUP, SEPARATOR_OP},
{MATH_SUP, TK_WHILE},
{MATH_SUP, TK_UNTIL},
{MATH_SUP, TK_DO},
{MATH_SUP, TK_IF},
{MATH_SUP, TK_ELIF},
{MATH_SUP, TK_THEN},
{MATH_SUP, TK_ELSE},
{MATH_SUP, COMPOUND_LIST},
{MATH_SUP, COMPLETE_CONDITION},
{MATH_SUP, CONDITION},
{MATH_SUP, TK_PAREN_OPEN},
{MATH_SUP, TK_LBRACE},
{MATH_SUP, SEQUENCE},
{MATH_SUP, COMPLETE_COMMANDS},
{MATH_SUP, AND_OR_MAJOR},
{MATH_SUP, TK_BANG},
{SIMPLE_COMMAND, TK_WHILE}, {SIMPLE_COMMAND, TK_WHILE},
{SIMPLE_COMMAND, TK_UNTIL}, {SIMPLE_COMMAND, TK_UNTIL},
{SIMPLE_COMMAND, TK_DO}, {SIMPLE_COMMAND, TK_DO},

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 17:58:34 by ariard #+# #+# */ /* Created: 2017/02/09 17:58:34 by ariard #+# #+# */
/* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */ /* Updated: 2017/03/14 22:03:42 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -80,7 +80,6 @@ t_prodmatch g_prodmatch[] =
{TK_NAME, SEPARATOR_OP, FNAME}, {TK_NAME, SEPARATOR_OP, FNAME},
{TK_NAME, NEWLINE_LIST, FNAME}, {TK_NAME, NEWLINE_LIST, FNAME},
{TK_NAME, TK_FOR, NAME}, {TK_NAME, TK_FOR, NAME},
{TK_NEWLINE, MATH_SUP, NEWLINE_LIST},
{TK_NEWLINE, CASE_LIST_NS, NEWLINE_LIST}, {TK_NEWLINE, CASE_LIST_NS, NEWLINE_LIST},
{TK_NEWLINE, TK_DO, NEWLINE_LIST}, {TK_NEWLINE, TK_DO, NEWLINE_LIST},
{TK_NEWLINE, TK_PAREN_CLOSE, NEWLINE_LIST}, {TK_NEWLINE, TK_PAREN_CLOSE, NEWLINE_LIST},
@ -111,12 +110,10 @@ t_prodmatch g_prodmatch[] =
{TK_NEWLINE, FOR_WORDLIST, NEWLINE_LIST}, {TK_NEWLINE, FOR_WORDLIST, NEWLINE_LIST},
{TK_NEWLINE, SEQUENTIAL_SEP, NEWLINE_LIST}, {TK_NEWLINE, SEQUENTIAL_SEP, NEWLINE_LIST},
{TK_NEWLINE, PROGRAM, NEWLINE_LIST}, {TK_NEWLINE, PROGRAM, NEWLINE_LIST},
{TK_SEMI, MATH_SUP, SEPARATOR_OP},
{TK_SEMI, CMD_SUPERIOR, SEPARATOR_OP}, {TK_SEMI, CMD_SUPERIOR, SEPARATOR_OP},
{TK_SEMI, LIST, SEPARATOR_OP}, {TK_SEMI, LIST, SEPARATOR_OP},
{TK_SEMI, PIPE_SEMI_SEQUENCE, SEPARATOR_OP}, {TK_SEMI, PIPE_SEMI_SEQUENCE, SEPARATOR_OP},
{TK_SEMI, PIPE_CLOSE_SEQUENCE, SEPARATOR_OP}, {TK_SEMI, PIPE_CLOSE_SEQUENCE, SEPARATOR_OP},
{TK_AMP, MATH_SUP, SEPARATOR_OP},
{TK_AMP, CMD_SUPERIOR, SEPARATOR_OP}, {TK_AMP, CMD_SUPERIOR, SEPARATOR_OP},
{TK_AMP, LIST, SEPARATOR_OP}, {TK_AMP, LIST, SEPARATOR_OP},
{TK_AMP, PIPE_SEMI_SEQUENCE, SEPARATOR_OP}, {TK_AMP, PIPE_SEMI_SEQUENCE, SEPARATOR_OP},

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 15:32:10 by ariard #+# #+# */ /* Created: 2017/02/09 15:32:10 by ariard #+# #+# */
/* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */ /* Updated: 2017/03/14 22:11:43 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */