modifs var

This commit is contained in:
Antoine Riard 2017-03-14 00:52:51 +01:00
parent 95cebeaded
commit f02222d882
21 changed files with 119 additions and 107 deletions

View file

@ -283,7 +283,6 @@ parser/add_number.c\
parser/add_redir.c\ parser/add_redir.c\
parser/add_sep.c\ parser/add_sep.c\
parser/add_subshell.c\ parser/add_subshell.c\
parser/add_var.c\
parser/aggregate_sym.c\ parser/aggregate_sym.c\
parser/build_tree.c\ parser/build_tree.c\
parser/error_syntax.c\ parser/error_syntax.c\

View file

@ -120,7 +120,6 @@ int add_func_cmd(t_btree **ast, t_list **lst);
int add_func_sep(t_btree **ast, t_list **lst); int add_func_sep(t_btree **ast, t_list **lst);
int add_one_func(t_btree **ast, t_list **lst); int add_one_func(t_btree **ast, t_list **lst);
int add_pipe(t_btree **ast, t_list **lst); int add_pipe(t_btree **ast, t_list **lst);
int add_var(t_btree **ast, t_list **lst);
int add_null(t_btree **ast, t_list **lst); int add_null(t_btree **ast, t_list **lst);
int add_ionumber(t_btree **ast, t_list **lst); int add_ionumber(t_btree **ast, t_list **lst);
int add_bang(t_btree **ast, t_list **lst); int add_bang(t_btree **ast, t_list **lst);
@ -141,7 +140,6 @@ int isdir(t_btree **ast);
int iscondition(t_btree **ast, t_list **list); int iscondition(t_btree **ast, t_list **list);
int isdir_sep(t_btree **ast, t_list **list); 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 isvar(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(t_btree **ast, t_list **lst);

View file

@ -6,7 +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/13 20:39:05 by jhalford ### ########.fr */ /* Updated: 2017/03/14 00:49:40 by ariard ### ########.fr */
/* Updated: 2017/03/07 18:35:11 by jhalford ### ########.fr */ /* Updated: 2017/03/07 18:35:11 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -118,7 +118,7 @@ enum e_sym
TK_ELSE, TK_ELSE,
TK_UNTIL, TK_UNTIL,
TK_WORD, TK_WORD,
TK_ASSIGNEMENT_WORD = 50, TK_ASSIGNMENT_WORD = 50,
TK_BANG, TK_BANG,
TK_NAME, TK_NAME,
TK_FOR, TK_FOR,

@ -1 +1 @@
Subproject commit 9382dc10fdb91892ab26604a5776e5301ab88b71 Subproject commit b209bb1fb718a68256253d5ab5ff69a46a90d5d6

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/13 18:10:37 by jhalford ### ########.fr */ /* Updated: 2017/03/14 00:44:32 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -21,9 +21,12 @@ int builtin_setenv(const char *path, char *const av[], char *const envp[])
(void)envp; (void)envp;
(void)path; (void)path;
i = 0; i = 0;
env = &data_singleton()->env; DG("in setenv");
env = ft_strcmp(av[0], "local") == 0 ?
&data_singleton()->local_var : &data_singleton()->env;
if (ft_strcmp(av[0], "setenv") == 0 if (ft_strcmp(av[0], "setenv") == 0
|| ft_strcmp(av[0], "export") == 0) || ft_strcmp(av[0], "export") == 0
|| ft_strcmp(av[0], "local") == 0)
av++; av++;
if (!av[0]) if (!av[0])
{ {
@ -34,7 +37,7 @@ int builtin_setenv(const char *path, char *const av[], char *const envp[])
{ {
DG("str3join(%s,%s,%s)", av[0], "=", av[1]); DG("str3join(%s,%s,%s)", av[0], "=", av[1]);
str = ft_str3join(av[0], "=", av[1]); str = ft_str3join(av[0], "=", av[1]);
while ((*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: 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/07 16:00:24 by wescande ### ########.fr */ /* Updated: 2017/03/13 23:59:50 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,7 +17,7 @@ static int get_math(char *stream, char **var, char **value, char **operator)
char *temp; char *temp;
*var = ft_strduptr(stream, &ft_isalpha); *var = ft_strduptr(stream, &ft_isalpha);
temp = ft_sstrstr(data_singleton()->env, *var); temp = ft_sstrstr(data_singleton()->local_var, *var);
if (temp) if (temp)
{ {
temp += ft_strlenchr(temp, '=') + 1; temp += ft_strlenchr(temp, '=') + 1;
@ -70,8 +70,12 @@ int exec_math(t_btree **ast)
node = (*ast)->item; node = (*ast)->item;
av = token_to_argv(node->data.cmd.wordlist, 1); av = token_to_argv(node->data.cmd.wordlist, 1);
DG("before get math : %s", av[0]);
get_math(av[0], &var, &value, &operator); get_math(av[0], &var, &value, &operator);
DG("before do math var %s value %s operator %s", var, value, operator);
do_math(&value, operator); do_math(&value, operator);
builtin_setenv("setenv", (char *[]){var, value, 0}, data_singleton()->local_var); DG("before setenv %s", value);
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 <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/13 20:24:01 by jhalford ### ########.fr */ /* Updated: 2017/03/14 00:49:02 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -28,7 +28,7 @@ t_itof g_execmap[] =
{TK_FOR, &exec_leaf}, {TK_FOR, &exec_leaf},
{TK_CASE, &exec_leaf}, {TK_CASE, &exec_leaf},
{TK_PAREN_OPEN, &exec_case_branch}, {TK_PAREN_OPEN, &exec_case_branch},
{TK_ASSIGNEMENT_WORD, &exec_var}, {TK_ASSIGNMENT_WORD, &exec_var},
{MATH, &exec_math}, {MATH, &exec_math},
{SUBSHELL, &exec_leaf}, {SUBSHELL, &exec_leaf},
{TK_LBRACE, &exec_leaf}, {TK_LBRACE, &exec_leaf},

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/08 12:01:07 by jhalford ### ########.fr */ /* Updated: 2017/03/14 00:49:02 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -25,7 +25,7 @@ void *node_copy(void *data)
new->full = old->full; new->full = old->full;
new->type = old->type; new->type = old->type;
new->pattern = old->pattern; new->pattern = old->pattern;
if (old->type == CMD || old->type == TK_ASSIGNEMENT_WORD) if (old->type == CMD || old->type == TK_ASSIGNMENT_WORD)
{ {
new->data.cmd.redir = ft_lstmap(old->data.cmd.redir, &redir_copy); new->data.cmd.redir = ft_lstmap(old->data.cmd.redir, &redir_copy);
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);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */ /* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
/* Updated: 2017/03/11 18:14:33 by jhalford ### ########.fr */ /* Updated: 2017/03/13 23:41:15 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/24 20:28:13 by ariard #+# #+# */ /* Created: 2017/02/24 20:28:13 by ariard #+# #+# */
/* Updated: 2017/03/11 20:48:34 by ariard ### ########.fr */ /* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,13 +18,13 @@ int lexer_assignement_word(t_list **alst, t_lexer *lexer)
char c; char c;
token = (*alst)->content; token = (*alst)->content;
if (token->type != TK_WORD && token->type != TK_ASSIGNEMENT_WORD) if (token->type != TK_WORD && token->type != TK_ASSIGNMENT_WORD)
{ {
token_append(token, lexer, 0, 0); token_append(token, lexer, 0, 0);
lexer->pos++; lexer->pos++;
return (lexer_lex(alst, lexer)); return (lexer_lex(alst, lexer));
} }
token->type = TK_ASSIGNEMENT_WORD; token->type = TK_ASSIGNMENT_WORD;
token_append(token, lexer, 0, 0); token_append(token, lexer, 0, 0);
lexer->pos++; lexer->pos++;
c = lexer->str[lexer->pos]; c = lexer->str[lexer->pos];

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
/* Updated: 2017/03/11 19:19:57 by ariard ### ########.fr */ /* Updated: 2017/03/13 23:48:04 by ariard ### ########.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/10 17:56:38 by ariard ### ########.fr */ /* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -37,7 +37,7 @@ char *ft_putast(void *nodein)
return ("FNAME"); return ("FNAME");
if (node->type == TK_LBRACE) if (node->type == TK_LBRACE)
return ("TK_LBRACE"); return ("TK_LBRACE");
if (node->type == TK_ASSIGNEMENT_WORD) if (node->type == TK_ASSIGNMENT_WORD)
return ("ASSIGNEMENT_WORD"); return ("ASSIGNEMENT_WORD");
if (node->type == SUBSHELL) if (node->type == SUBSHELL)
return ("SUBSHELL"); return ("SUBSHELL");

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/13 22:45:29 by ariard ### ########.fr */ /* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,7 +17,6 @@ t_distrostree g_distrostree[] =
{&superflous_token, &add_null}, {&superflous_token, &add_null},
{&isdir_sep, &add_redir_type}, {&isdir_sep, &add_redir_type},
{&isdir_word, &add_redir_word}, {&isdir_word, &add_redir_word},
{&isvar, &add_var},
{&isloop_condition, &add_loop_condition}, {&isloop_condition, &add_loop_condition},
{&isloop, &add_loop_cmd}, {&isloop, &add_loop_cmd},
{&iscondition_branch, &add_branch}, {&iscondition_branch, &add_branch},
@ -59,7 +58,8 @@ static int no_del_token(t_btree **ast, t_list **lst)
{ {
node = (*ast)->item; node = (*ast)->item;
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)
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 < 19) while (++i < 18)
{ {
if (g_distrostree[i].test(ast, lst) == 1) if (g_distrostree[i].test(ast, lst) == 1)
{ {
@ -89,10 +89,13 @@ int add_cmd(t_btree **ast, t_list **lst)
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)
{
DG("type is %s", read_state(token->type));
node->type = token->type; node->type = token->type;
}
else else
node->type = CMD; node->type = CMD;
if (token->type == TK_WORD || token->type == TK_ASSIGNEMENT_WORD) if (token->type == TK_WORD || token->type == TK_ASSIGNMENT_WORD)
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));
return (0); return (0);

View file

@ -1,46 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* add_var.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/03 15:08:16 by ariard #+# #+# */
/* Updated: 2017/03/13 17:36:24 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int isvar(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_ASSIGNEMENT_WORD
&& token->type == TK_ASSIGNEMENT_WORD)
return (1);
}
return (0);
}
int add_var(t_btree **ast, t_list **lst)
{
t_astnode *node;
t_btree *new_node;
if (!*ast)
return (0);
new_node = NULL;
gen_node(&new_node);
join_ast(ast, &new_node);
node = (new_node)->item;
node->type = TK_SEMI;
add_cmd(&new_node, lst);
return (0);
}

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/13 20:36:45 by ariard ### ########.fr */ /* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -31,7 +31,7 @@ t_aggrematch g_aggrematch[] =
{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, TK_PAREN_OPEN, MATH, TK_PAREN_OPEN},
{TK_PAREN_OPEN, CMD_SUPERIOR, OPEN_FUNC, 0}, {TK_PAREN_OPEN, CMD_SUPERIOR, OPEN_FUNC, 0},
{TK_ASSIGNEMENT_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},
{TK_PIPE, PIPE_SEMI_SEQUENCE, SEQUENCE, PIPE_SEMI_SEQUENCE}, {TK_PIPE, PIPE_SEMI_SEQUENCE, SEQUENCE, PIPE_SEMI_SEQUENCE},
{TK_PIPE, PIPE_CLOSE_SEQUENCE, SEQUENCE, PIPE_CLOSE_SEQUENCE}, {TK_PIPE, PIPE_CLOSE_SEQUENCE, SEQUENCE, PIPE_CLOSE_SEQUENCE},
@ -404,7 +404,7 @@ int aggregate_sym(t_list **stack, t_sym *new_sym, t_parstate *state)
{ {
pop_stack(stack, g_aggrematch[i].erase_sym); pop_stack(stack, g_aggrematch[i].erase_sym);
head = (*stack)->content; head = (*stack)->content;
// DG("stack after pop: %s", read_state(*head)); // DG("stack after pop: %s", read_state(*head));
} }
if (eval_sym(stack, *new_sym)) if (eval_sym(stack, *new_sym))
{ {

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 18:32:59 by ariard #+# #+# */ /* Created: 2017/02/15 18:32:59 by ariard #+# #+# */
/* Updated: 2017/03/13 19:28:58 by ariard ### ########.fr */ /* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -46,7 +46,7 @@ t_treematch g_treematch[] =
{TK_PAREN_CLOSE, &add_cmd}, {TK_PAREN_CLOSE, &add_cmd},
{TK_FOR, &add_cmd}, {TK_FOR, &add_cmd},
{TK_NAME, &add_cmd}, {TK_NAME, &add_cmd},
{TK_ASSIGNEMENT_WORD, &add_cmd}, {TK_ASSIGNMENT_WORD, &add_cmd},
{SUBSHELL, &add_cmd}, {SUBSHELL, &add_cmd},
{TK_LBRACE, &add_cmd}, {TK_LBRACE, &add_cmd},
{TK_RBRACE, &add_cmd}, {TK_RBRACE, &add_cmd},
@ -58,14 +58,16 @@ static int isseparator(t_token *token, int cache)
{ {
if (token->type == TK_NEWLINE && (cache == TK_WHILE || cache == TK_DO if (token->type == TK_NEWLINE && (cache == TK_WHILE || cache == TK_DO
|| cache == TK_NEWLINE || cache == TK_THEN || cache == TK_IN || cache == TK_NEWLINE || cache == TK_THEN || cache == TK_IN
|| cache == TK_DSEMI)) || cache == TK_DSEMI || cache == SUBSHELL || cache == TK_ELIF
|| cache == TK_ELSE || cache == TK_ELSE || cache == TK_CASE
|| cache == TK_FOR || cache == TK_UNTIL))
return (0); return (0);
return (1); return (1);
} }
static int check_cache(t_token *token, int cache) static int check_cache(t_token *token, int cache)
{ {
if (token->type == TK_ASSIGNEMENT_WORD && cache == TK_WORD) if (token->type == TK_ASSIGNMENT_WORD && cache == TK_WORD)
token->type = TK_WORD; token->type = TK_WORD;
if (token->type == TK_PAREN_OPEN && cache != TK_IN && cache != TK_DSEMI if (token->type == TK_PAREN_OPEN && cache != TK_IN && cache != TK_DSEMI
&& cache != TK_WORD) && cache != TK_WORD)

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/13 20:36:26 by ariard ### ########.fr */ /* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -26,7 +26,7 @@ t_stackmatch g_stackmatch[] =
{TK_WORD, TK_IN}, {TK_WORD, TK_IN},
{TK_WORD, FOR_WORDLIST}, {TK_WORD, FOR_WORDLIST},
{TK_WORD, MATH}, {TK_WORD, MATH},
{TK_ASSIGNEMENT_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},
{TK_IO_NUMBER, CMD_PREFIX}, {TK_IO_NUMBER, CMD_PREFIX},
@ -784,14 +784,62 @@ t_stackmatch g_stackmatch[] =
{MATH, NEWLINE_LIST}, {MATH, NEWLINE_LIST},
{MATH, SEPARATOR}, {MATH, SEPARATOR},
{MATH, SEPARATOR_OP}, {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, LINEBREAK},
{MATH_PLUS, NEWLINE_LIST}, {MATH_PLUS, NEWLINE_LIST},
{MATH_PLUS, SEPARATOR}, {MATH_PLUS, SEPARATOR},
{MATH_PLUS, SEPARATOR_OP}, {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, LINEBREAK},
{MATH_SUP, NEWLINE_LIST}, {MATH_SUP, NEWLINE_LIST},
{MATH_SUP, SEPARATOR}, {MATH_SUP, SEPARATOR},
{MATH_SUP, SEPARATOR_OP}, {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/13 20:37:27 by ariard ### ########.fr */ /* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -54,24 +54,24 @@ t_prodmatch g_prodmatch[] =
{TK_WORD, CASE_LIST, PATTERN}, {TK_WORD, CASE_LIST, PATTERN},
{TK_WORD, PATTERN_CASE, PATTERN}, {TK_WORD, PATTERN_CASE, PATTERN},
{TK_WORD, COMPLETE_COMMANDS, CMD_NAME}, {TK_WORD, COMPLETE_COMMANDS, CMD_NAME},
{TK_ASSIGNEMENT_WORD, TK_BANG, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_BANG, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, LINEBREAK, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, LINEBREAK, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, TK_PAREN_OPEN, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_PAREN_OPEN, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, TK_LBRACE, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_LBRACE, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, TK_BANG, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_BANG, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, SEPARATOR_OP, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, SEPARATOR_OP, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, TK_WHILE, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_WHILE, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, TK_UNTIL, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_UNTIL, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, TK_FOR, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_FOR, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, TK_IF, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_IF, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, TK_FI, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_FI, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, TK_ELIF, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_ELIF, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, TK_ELSE, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, TK_ELSE, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, NEWLINE_LIST, CMD_PREFIX}, {TK_ASSIGNMENT_WORD, NEWLINE_LIST, CMD_PREFIX},
{TK_ASSIGNEMENT_WORD, CMD_NAME, CMD_SUFFIX}, {TK_ASSIGNMENT_WORD, CMD_NAME, CMD_SUFFIX},
{TK_ASSIGNEMENT_WORD, CMD_SUPERIOR, CMD_SUFFIX}, {TK_ASSIGNMENT_WORD, CMD_SUPERIOR, CMD_SUFFIX},
{TK_ASSIGNEMENT_WORD, PIPE_SEMI_SEQUENCE, CMD_SUFFIX}, {TK_ASSIGNMENT_WORD, PIPE_SEMI_SEQUENCE, CMD_SUFFIX},
{TK_ASSIGNEMENT_WORD, CMD_WORD, CMD_SUFFIX}, {TK_ASSIGNMENT_WORD, CMD_WORD, CMD_SUFFIX},
{TK_NAME, TK_BANG, FNAME}, {TK_NAME, TK_BANG, FNAME},
{TK_NAME, LINEBREAK, FNAME}, {TK_NAME, LINEBREAK, FNAME},
{TK_NAME, TK_PAREN_OPEN, FNAME}, {TK_NAME, TK_PAREN_OPEN, FNAME},

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/13 19:52:30 by ariard ### ########.fr */ /* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -40,8 +40,8 @@ char *read_state(t_sym current)
return ("TK_LBRACE"); return ("TK_LBRACE");
if (current == TK_RBRACE) if (current == TK_RBRACE)
return ("TK_RBRACE"); return ("TK_RBRACE");
if (current == TK_ASSIGNEMENT_WORD) if (current == TK_ASSIGNMENT_WORD)
return ("TK_ASSIGNEMENT_WORD"); return ("TK_ASSIGNMENT_WORD");
if (current == CASE_CLAUSE) if (current == CASE_CLAUSE)
return ("CASE_CLAUSE"); return ("CASE_CLAUSE");
if (current == CASE_LIST_NS) if (current == CASE_LIST_NS)

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 18:57:44 by ariard #+# #+# */ /* Created: 2017/02/15 18:57:44 by ariard #+# #+# */
/* Updated: 2017/03/11 18:28:50 by ariard ### ########.fr */ /* Updated: 2017/03/14 00:36:34 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

1
42sh/test.sh Normal file
View file

@ -0,0 +1 @@
ls