math as a builtin
This commit is contained in:
parent
dce9df5008
commit
8791eae9c3
23 changed files with 69 additions and 187 deletions
|
|
@ -6,7 +6,7 @@
|
|||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# 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_hash.c\
|
||||
builtin/builtin_history.c\
|
||||
builtin/builtin_math.c\
|
||||
builtin/builtin_read.c\
|
||||
builtin/builtin_setenv.c\
|
||||
builtin/builtin_unset.c\
|
||||
|
|
@ -72,7 +73,6 @@ exec/exec_case_branch.c\
|
|||
exec/exec_elif.c\
|
||||
exec/exec_else.c\
|
||||
exec/exec_leaf.c\
|
||||
exec/exec_math.c\
|
||||
exec/exec_or_if.c\
|
||||
exec/exec_pipe.c\
|
||||
exec/exec_reset.c\
|
||||
|
|
@ -279,7 +279,6 @@ parser/add_cmd.c\
|
|||
parser/add_condition.c\
|
||||
parser/add_func.c\
|
||||
parser/add_loop.c\
|
||||
parser/add_math.c\
|
||||
parser/add_number.c\
|
||||
parser/add_redir.c\
|
||||
parser/add_sep.c\
|
||||
|
|
|
|||
|
|
@ -30,5 +30,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_history(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
|
||||
|
|
|
|||
|
|
@ -142,8 +142,6 @@ int isdir_sep(t_btree **ast, t_list **list);
|
|||
int isdir_word(t_btree **ast, t_list **list);
|
||||
int isnull(t_btree **ast, t_list **list);
|
||||
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_sep(t_btree **ast, t_list **lst);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/14 00:49:40 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/14 22:04:24 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/07 18:35:11 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
|
@ -197,9 +197,6 @@ enum e_sym
|
|||
OPEN_FUNC,
|
||||
CLOSE_FUNC,
|
||||
CLOSE_LIST,
|
||||
MATH,
|
||||
MATH_PLUS,
|
||||
MATH_SUP,
|
||||
REDIR,
|
||||
CMD,
|
||||
HEREDOCDATA,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit fb9b737be2598ec204afb974ec02f7bce5261b6b
|
||||
Subproject commit 9382dc10fdb91892ab26604a5776e5301ab88b71
|
||||
12
42sh/main.c
Normal file
12
42sh/main.c
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = malloc(5);
|
||||
fork();
|
||||
free(s);
|
||||
sleep(100);
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -6,17 +6,25 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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"
|
||||
|
||||
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;
|
||||
|
||||
*var = ft_strduptr(stream, &ft_isalpha);
|
||||
temp = ft_sstrstr(data_singleton()->local_var, *var);
|
||||
if (temp)
|
||||
{
|
||||
|
|
@ -30,21 +38,21 @@ static int get_math(char *stream, char **var, char **value, char **operator)
|
|||
}
|
||||
else
|
||||
*value = ft_itoa(0);
|
||||
stream += ft_strlen(*var);
|
||||
*operator = ft_strdup(stream);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int do_math(char **value, char *operator)
|
||||
static int do_math(char **value, char *operator, char *operand)
|
||||
{
|
||||
long ope1;
|
||||
long ope2;
|
||||
|
||||
ope1 = ft_atoi(*value);
|
||||
if (operator[2])
|
||||
ope2 = ft_atoi(&operator[2]);
|
||||
if (operand)
|
||||
ope2 = ft_atoi(operand);
|
||||
else
|
||||
ope2 = 0;
|
||||
if (ft_strlen(operator) > 1)
|
||||
return (0);
|
||||
if ((operator[0] == '/' || operator[0] == '%') && ope2 == 0)
|
||||
ope1 = 0;
|
||||
else
|
||||
|
|
@ -60,22 +68,22 @@ static int do_math(char **value, char *operator)
|
|||
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 *value;
|
||||
char *operator;
|
||||
char *operand;
|
||||
|
||||
node = (*ast)->item;
|
||||
av = token_to_argv(node->data.cmd.wordlist, 1);
|
||||
DG("before get math : %s", av[0]);
|
||||
get_math(av[0], &var, &value, &operator);
|
||||
DG("before do math var %s value %s operator %s", var, value, operator);
|
||||
do_math(&value, operator);
|
||||
DG("before setenv %s", value);
|
||||
(void)path;
|
||||
(void)envp;
|
||||
init_math(&var, &value, &operator, &operand);
|
||||
var = av[1];
|
||||
get_value(&var, &value);
|
||||
operator = av[2];
|
||||
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);
|
||||
DG("after setenv");
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:25:17 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/14 00:44:32 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/14 22:44:18 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -21,7 +21,6 @@ int builtin_setenv(const char *path, char *const av[], char *const envp[])
|
|||
(void)envp;
|
||||
(void)path;
|
||||
i = 0;
|
||||
DG("in setenv");
|
||||
env = ft_strcmp(av[0], "local") == 0 ?
|
||||
&data_singleton()->local_var : &data_singleton()->env;
|
||||
if (ft_strcmp(av[0], "setenv") == 0
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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},
|
||||
{"hash", &builtin_hash},
|
||||
{"history", &builtin_history},
|
||||
{"math", &builtin_math},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* ************************************************************************** */
|
||||
/*ss ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* exec_leaf.c :+: :+: :+: */
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/13 23:56:53 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/14 21:49:17 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 11:12:05 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/07 18:37:38 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/14 19:56:38 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -30,6 +30,6 @@ int exec_var(t_btree **ast)
|
|||
node = (*ast)->item;
|
||||
av = token_to_argv(node->data.cmd.token, 1);
|
||||
set_var(av[0], &var, &value);
|
||||
builtin_setenv("setenv", (char*[]){var, value, 0}, data_singleton()->local_var);
|
||||
builtin_setenv("setenv", (char*[]){"local", var, value, 0}, data_singleton()->local_var);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/14 00:49:02 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/14 22:10:56 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -29,7 +29,6 @@ t_itof g_execmap[] =
|
|||
{TK_CASE, &exec_leaf},
|
||||
{TK_PAREN_OPEN, &exec_case_branch},
|
||||
{TK_ASSIGNMENT_WORD, &exec_var},
|
||||
{MATH, &exec_math},
|
||||
{SUBSHELL, &exec_leaf},
|
||||
{TK_LBRACE, &exec_leaf},
|
||||
{TK_BANG, &exec_bang},
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
return ("TK_BANG");
|
||||
if (node->type == MATH)
|
||||
return ("MATH");
|
||||
if (node->type == MATH_PLUS)
|
||||
return ("MATH_PLUS");
|
||||
if (node->type == TK_DSEMI)
|
||||
return ("TK_DSEMI");
|
||||
if (node->type == WORDLIST)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/14 17:05:45 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/14 22:09:29 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ int handle_instruction(int fd)
|
|||
}
|
||||
btree_print(STDBUG, ast, &ft_putast);
|
||||
if (ft_exec(&ast))
|
||||
return (1);
|
||||
return (2);
|
||||
instruction_free(&token, &parser, &ast);
|
||||
if (SH_IS_INTERACTIVE(data_singleton()->opts) && *lexer.str)
|
||||
ft_add_str_in_history(lexer.str);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/04 20:42:13 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/13 22:38:44 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/14 21:45:03 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -94,8 +94,9 @@ int add_pattern(t_btree **ast, t_list **lst)
|
|||
|
||||
token = (*lst)->content;
|
||||
node = (*ast)->item;
|
||||
DG("token type is %s", read_state(token->type));
|
||||
DG("node type is %s", read_state(node->type));
|
||||
ft_ld_pushback(&node->data.cmd.wordlist,
|
||||
ft_ld_pushback(&node->data.cmd.token,
|
||||
gen_tab(token->data, token->esc, token->esc2, 1));
|
||||
node->pattern = 1;
|
||||
return (0);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/15 20:49:15 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/14 00:50:34 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/14 22:22:15 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -24,8 +24,6 @@ t_distrostree g_distrostree[] =
|
|||
{&iscase_pattern, &add_pattern},
|
||||
{&iscase, &add_case_cmd},
|
||||
{&iscase_branch, &add_branch},
|
||||
{&ismath, &add_null},
|
||||
{&ismath_expr, &add_pattern},
|
||||
{&issubshell, &add_subshell_cmd},
|
||||
{&isfunc_name, &add_null},
|
||||
{&isfunc, &add_func_cmd},
|
||||
|
|
@ -72,7 +70,7 @@ int add_cmd(t_btree **ast, t_list **lst)
|
|||
int i;
|
||||
|
||||
i = -1;
|
||||
while (++i < 18)
|
||||
while (++i < 16)
|
||||
{
|
||||
if (g_distrostree[i].test(ast, lst) == 1)
|
||||
{
|
||||
|
|
@ -96,7 +94,10 @@ int add_cmd(t_btree **ast, t_list **lst)
|
|||
else
|
||||
node->type = CMD;
|
||||
if (token->type == TK_WORD || token->type == TK_ASSIGNMENT_WORD)
|
||||
{
|
||||
DG("token data is %s", token->data);
|
||||
ft_ld_pushback(&node->data.cmd.token,
|
||||
gen_tab(token->data, token->esc, token->esc2, 1));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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_IN, FOR_WORDLIST, TK_IN},
|
||||
{TK_WORD, FOR_WORDLIST, FOR_WORDLIST, FOR_WORDLIST},
|
||||
{TK_WORD, MATH, MATH, MATH},
|
||||
{TK_SEMI, FOR_WORDLIST, SEQUENTIAL_SEP, 0},
|
||||
{TK_DSEMI, CMD_SUPERIOR, PIPE_SEQUENCE, CMD_SUPERIOR},
|
||||
{TK_DSEMI, PIPE_SEMI_SEQUENCE, PIPE_SEQUENCE, PIPE_SEMI_SEQUENCE},
|
||||
{TK_DSEMI, PIPE_CLOSE_SEQUENCE, PIPE_SEQUENCE, PIPE_CLOSE_SEQUENCE},
|
||||
{TK_PAREN_OPEN, TK_IN, 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_ASSIGNMENT_WORD, CMD_PREFIX, CMD_PREFIX, 0},
|
||||
{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, CASE_LIST_NS, CASE_CLAUSE, TK_CASE},
|
||||
{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, CMD_SUPERIOR, 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, CMD_SUPERIOR, AND_OR_MINOR, CMD_SUPERIOR},
|
||||
{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, COMPOUND_LIST, SEPARATOR, 0},
|
||||
{SEPARATOR_OP, CASE_LIST_NS, SEPARATOR, 0},
|
||||
{SEPARATOR_OP, PIPE_SEMI_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, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS},
|
||||
{SEPARATOR, COMPOUND_LIST, COMPOUND_LIST, COMPOUND_LIST},
|
||||
{SEPARATOR, PIPE_SEMI_SEQUENCE, PIPE_SEQUENCE, PIPE_SEMI_SEQUENCE},
|
||||
{SEPARATOR, PIPE_CLOSE_SEQUENCE, PIPE_SEQUENCE, PIPE_CLOSE_SEQUENCE},
|
||||
{LINEBREAK, MATH_SUP, CMD_SUPERIOR, MATH_SUP},
|
||||
{LINEBREAK, SEPARATOR_OP, SEPARATOR, SEPARATOR_OP},
|
||||
{LINEBREAK, TK_SEMI, SEQUENTIAL_SEP, TK_SEMI},
|
||||
{LINEBREAK, TK_PAREN_CLOSE, FUNC, FNAME},
|
||||
|
|
@ -87,7 +80,6 @@ t_aggrematch g_aggrematch[] =
|
|||
{LINEBREAK, PIPE_CLOSE_SEQUENCE, PIPE_SEQUENCE, PIPE_CLOSE_SEQUENCE},
|
||||
{LINEBREAK, COMPOUND_LIST, COMPOUND_LIST, COMPOUND_LIST},
|
||||
{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, SEQUENTIAL_SEP, SEQUENTIAL_SEP, SEQUENTIAL_SEP},
|
||||
{NEWLINE_LIST, TK_DO, TK_DO, TK_DO},
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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, TK_IN},
|
||||
{TK_WORD, FOR_WORDLIST},
|
||||
{TK_WORD, MATH},
|
||||
{TK_ASSIGNMENT_WORD, CMD_PREFIX},
|
||||
{TK_IO_NUMBER, REDIRECT_LIST},
|
||||
{TK_IO_NUMBER, CMD_SUFFIX},
|
||||
|
|
@ -501,14 +500,12 @@ t_stackmatch g_stackmatch[] =
|
|||
{END_COMMAND, CASE_LIST_NS},
|
||||
{END_COMMAND, COMPLETE_CONDITION},
|
||||
{END_COMMAND, CONDITION},
|
||||
{SEPARATOR, MATH_SUP},
|
||||
{SEPARATOR, CMD_SUPERIOR},
|
||||
{SEPARATOR, TERM},
|
||||
{SEPARATOR, COMPOUND_LIST},
|
||||
{SEPARATOR, CASE_LIST_NS},
|
||||
{SEPARATOR, PIPE_SEMI_SEQUENCE},
|
||||
{SEPARATOR, PIPE_CLOSE_SEQUENCE},
|
||||
{SEPARATOR_OP, MATH_SUP},
|
||||
{SEPARATOR_OP, CMD_SUPERIOR},
|
||||
{SEPARATOR_OP, LIST},
|
||||
{SEPARATOR_OP, TERM},
|
||||
|
|
@ -516,7 +513,6 @@ t_stackmatch g_stackmatch[] =
|
|||
{SEPARATOR_OP, COMPOUND_LIST},
|
||||
{SEPARATOR_OP, PIPE_SEMI_SEQUENCE},
|
||||
{SEPARATOR_OP, PIPE_CLOSE_SEQUENCE},
|
||||
{LINEBREAK, MATH_SUP},
|
||||
{LINEBREAK, TK_SEMI},
|
||||
{LINEBREAK, END_COMMAND},
|
||||
{LINEBREAK, SEPARATOR_OP},
|
||||
|
|
@ -537,8 +533,6 @@ t_stackmatch g_stackmatch[] =
|
|||
{LINEBREAK, PROGRAM},
|
||||
{LINEBREAK, TK_PAREN_OPEN},
|
||||
{LINEBREAK, TK_LBRACE},
|
||||
{TK_PAREN_CLOSE, MATH},
|
||||
{TK_PAREN_CLOSE, MATH_PLUS},
|
||||
{TK_PAREN_CLOSE, TK_SEMI},
|
||||
{TK_PAREN_CLOSE, END_COMMAND},
|
||||
{TK_PAREN_CLOSE, SEPARATOR_OP},
|
||||
|
|
@ -557,8 +551,6 @@ t_stackmatch g_stackmatch[] =
|
|||
{TK_PAREN_CLOSE, COMPOUND_LIST},
|
||||
{TK_PAREN_CLOSE, FUNC_NAME},
|
||||
{TK_PAREN_CLOSE, OPEN_FUNC},
|
||||
{TK_RBRACE, MATH},
|
||||
{TK_RBRACE, MATH_PLUS},
|
||||
{TK_RBRACE, TK_SEMI},
|
||||
{TK_RBRACE, END_COMMAND},
|
||||
{TK_RBRACE, SEPARATOR_OP},
|
||||
|
|
@ -577,7 +569,6 @@ t_stackmatch g_stackmatch[] =
|
|||
{TK_RBRACE, PATTERN},
|
||||
{TK_RBRACE, COMPOUND_LIST},
|
||||
{TK_RBRACE, FUNC_NAME},
|
||||
{NEWLINE_LIST, MATH_SUP},
|
||||
{NEWLINE_LIST, TK_DO},
|
||||
{NEWLINE_LIST, CASE_LIST_NS},
|
||||
{NEWLINE_LIST, TK_PAREN_CLOSE},
|
||||
|
|
@ -780,66 +771,6 @@ t_stackmatch g_stackmatch[] =
|
|||
{CMD_SUPERIOR, AND_OR_MAJOR},
|
||||
{CLOSE_FUNC, CMD_SUPERIOR},
|
||||
{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_UNTIL},
|
||||
{SIMPLE_COMMAND, TK_DO},
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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, NEWLINE_LIST, FNAME},
|
||||
{TK_NAME, TK_FOR, NAME},
|
||||
{TK_NEWLINE, MATH_SUP, NEWLINE_LIST},
|
||||
{TK_NEWLINE, CASE_LIST_NS, NEWLINE_LIST},
|
||||
{TK_NEWLINE, TK_DO, 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, SEQUENTIAL_SEP, NEWLINE_LIST},
|
||||
{TK_NEWLINE, PROGRAM, NEWLINE_LIST},
|
||||
{TK_SEMI, MATH_SUP, SEPARATOR_OP},
|
||||
{TK_SEMI, CMD_SUPERIOR, SEPARATOR_OP},
|
||||
{TK_SEMI, LIST, SEPARATOR_OP},
|
||||
{TK_SEMI, PIPE_SEMI_SEQUENCE, SEPARATOR_OP},
|
||||
{TK_SEMI, PIPE_CLOSE_SEQUENCE, SEPARATOR_OP},
|
||||
{TK_AMP, MATH_SUP, SEPARATOR_OP},
|
||||
{TK_AMP, CMD_SUPERIOR, SEPARATOR_OP},
|
||||
{TK_AMP, LIST, SEPARATOR_OP},
|
||||
{TK_AMP, PIPE_SEMI_SEQUENCE, SEPARATOR_OP},
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue