merged new reidrection layout from pda
This commit is contained in:
commit
23cdcb2dbb
32 changed files with 140 additions and 137 deletions
|
|
@ -238,6 +238,7 @@ 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/add_var.c\
|
||||||
|
parser/add_number.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\
|
||||||
|
|
|
||||||
16
42sh/file
Normal file
16
42sh/file
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
total 576
|
||||||
|
-rwxr-xr-x 1 ariard 2016_paris 249036 Mar 5 17:14 42sh
|
||||||
|
-rw-r--r-- 1 ariard 2016_paris 8133 Mar 5 16:46 Makefile
|
||||||
|
-rw-r--r-- 1 ariard 2016_paris 16999 Mar 5 17:15 STDBUG
|
||||||
|
drwxr-xr-x 7 ariard 2016_paris 238 Mar 4 14:53 TESTSHELL
|
||||||
|
-rw-r--r-- 1 ariard 2016_paris 4396 Mar 4 14:53 donovan_segaults_06-02
|
||||||
|
-rw-r--r-- 1 ariard 2016_paris 0 Mar 5 17:15 file
|
||||||
|
drwxr-xr-x 16 ariard 2016_paris 544 Mar 5 16:46 includes
|
||||||
|
drwxr-xr-x 12 ariard 2016_paris 408 Mar 5 16:50 libft
|
||||||
|
drwxr-xr-x 13 ariard 2016_paris 442 Mar 5 16:50 objs
|
||||||
|
-rw-r--r-- 1 ariard 2016_paris 0 Mar 4 14:53 parser_init.c
|
||||||
|
drwxr-xr-x 6 ariard 2016_paris 204 Mar 4 14:53 pdf
|
||||||
|
drwxr-xr-x 29 ariard 2016_paris 986 Mar 4 14:53 sample
|
||||||
|
drwxr-xr-x 14 ariard 2016_paris 476 Mar 4 14:53 src
|
||||||
|
-rwxr-xr-x 1 ariard 2016_paris 890 Mar 4 14:53 test_framework.sh
|
||||||
|
-rwxr-xr-x 1 ariard 2016_paris 690 Mar 4 14:53 update_makefile.sh
|
||||||
|
|
@ -26,8 +26,6 @@ enum e_parstate
|
||||||
SUCCESS,
|
SUCCESS,
|
||||||
};
|
};
|
||||||
|
|
||||||
# define TK_REDIR(x) (TK_LESS <= x && x <= TK_GREATAND)
|
|
||||||
|
|
||||||
# define MATCH_STACK(x, y) (x == y || y == ALL)
|
# define MATCH_STACK(x, y) (x == y || y == ALL)
|
||||||
|
|
||||||
struct s_parser
|
struct s_parser
|
||||||
|
|
@ -127,6 +125,7 @@ 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_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_ionumbr(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 isloop_condition(t_btree **ast, t_list **lst);
|
||||||
|
|
@ -143,6 +142,7 @@ 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 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 join_ast(t_btree **ast, t_btree **new_node);
|
int join_ast(t_btree **ast, t_btree **new_node);
|
||||||
int gen_node(t_btree **ast);
|
int gen_node(t_btree **ast);
|
||||||
|
|
@ -156,17 +156,11 @@ struct s_distrostree
|
||||||
|
|
||||||
extern t_distrostree g_distrostree[];
|
extern t_distrostree g_distrostree[];
|
||||||
|
|
||||||
union u_word
|
|
||||||
{
|
|
||||||
char *word;
|
|
||||||
int fd;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct s_redir
|
struct s_redir
|
||||||
{
|
{
|
||||||
t_flag type;
|
t_flag type;
|
||||||
int n;
|
int n;
|
||||||
t_word word;
|
char *word;
|
||||||
int close;
|
int close;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -174,12 +168,12 @@ struct s_cmd
|
||||||
{
|
{
|
||||||
t_list *redir;
|
t_list *redir;
|
||||||
t_ld *token;
|
t_ld *token;
|
||||||
|
t_list *wordlist;
|
||||||
};
|
};
|
||||||
|
|
||||||
union u_astdata
|
union u_astdata
|
||||||
{
|
{
|
||||||
t_cmd cmd;
|
t_cmd cmd;
|
||||||
t_list *wordlist;
|
|
||||||
char **sstr;
|
char **sstr;
|
||||||
char *str;
|
char *str;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,4 @@
|
||||||
for i in hello bonjour salut comment
|
for i in hello bonjour salut comment
|
||||||
do
|
do
|
||||||
for i in echo
|
ls
|
||||||
do
|
|
||||||
pwd
|
|
||||||
done
|
|
||||||
for i in echo
|
|
||||||
do
|
|
||||||
pwd
|
|
||||||
done
|
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/05 11:50:51 by jhalford #+# #+# */
|
/* Created: 2016/12/05 11:50:51 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/05 15:58:16 by jhalford ### ########.fr */
|
/* Updated: 2017/03/05 18:05:43 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ void read_redir(void *data)
|
||||||
t_redir *redir;
|
t_redir *redir;
|
||||||
|
|
||||||
redir = data;
|
redir = data;
|
||||||
DG("file : [%s]", redir->word.word);
|
DG("file : [%s]", redir->word);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ast_free(void *data, size_t content_size)
|
void ast_free(void *data, size_t content_size)
|
||||||
|
|
@ -29,7 +29,7 @@ void ast_free(void *data, size_t content_size)
|
||||||
if (node->type == CMD)
|
if (node->type == CMD)
|
||||||
{
|
{
|
||||||
ft_ld_clear(&node->data.cmd.token, &ft_tabdel);
|
ft_ld_clear(&node->data.cmd.token, &ft_tabdel);
|
||||||
ft_lstdel(&node->data.cmd.redir, &redir_free);
|
// ft_lstdel(&node->data.cmd.redir, &redir_free);
|
||||||
}
|
}
|
||||||
// if (node->type == WORDLIST)
|
// if (node->type == WORDLIST)
|
||||||
// do clear
|
// do clear
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/06 20:42:20 by ariard #+# #+# */
|
/* Created: 2017/02/06 20:42:20 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/04 18:17:05 by ariard ### ########.fr */
|
/* Updated: 2017/03/05 15:22:49 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ int exec_for(t_btree **ast)
|
||||||
char *var;
|
char *var;
|
||||||
|
|
||||||
node = (*ast)->item;
|
node = (*ast)->item;
|
||||||
temp = node->data.wordlist;
|
temp = node->data.cmd.wordlist;
|
||||||
var = temp->content;
|
var = temp->content;
|
||||||
builtin_setenv("setenv", (char*[]){var, 0}, data_singleton()->local_var);
|
builtin_setenv("setenv", (char*[]){var, 0}, data_singleton()->local_var);
|
||||||
while (temp)
|
while (temp)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/03 18:12:57 by ariard #+# #+# */
|
/* Created: 2017/03/03 18:12:57 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/05 15:58:13 by jhalford ### ########.fr */
|
/* Updated: 2017/03/05 18:06:24 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,11 +20,9 @@ void redir_free(void *data, size_t content_size)
|
||||||
redir = data;
|
redir = data;
|
||||||
if (redir->type == TK_GREAT || redir->type == TK_LESS || redir->type == TK_DGREAT)
|
if (redir->type == TK_GREAT || redir->type == TK_LESS || redir->type == TK_DGREAT)
|
||||||
{
|
{
|
||||||
/* DG("word.word: %s", redir->word.word); */
|
ft_strdel(&redir->word);
|
||||||
ft_strdel(&redir->word.word);
|
|
||||||
}
|
}
|
||||||
/* else */
|
/* else */
|
||||||
/* redir->word.fd = 0; */
|
|
||||||
/* redir->type = 0; */
|
/* redir->type = 0; */
|
||||||
/* redir->n = 0; */
|
/* redir->n = 0; */
|
||||||
/* redir->close = 1; */
|
/* redir->close = 1; */
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/06 22:07:37 by jhalford #+# #+# */
|
/* Created: 2017/02/06 22:07:37 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/02/06 22:27:10 by jhalford ### ########.fr */
|
/* Updated: 2017/03/05 18:10:36 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ int redirect_dgreat(t_redir *redir)
|
||||||
int fdnew;
|
int fdnew;
|
||||||
|
|
||||||
fdnew = redir->n;
|
fdnew = redir->n;
|
||||||
if ((fdold = open(redir->word.word,
|
if ((fdold = open(redir->word,
|
||||||
O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0)
|
O_WRONLY | O_CREAT | O_APPEND, 0644)) < 0)
|
||||||
{
|
{
|
||||||
DG("open errno=%i", errno);
|
DG("open errno=%i", errno);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ int redirect_dless(t_redir *redir)
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
pipe(fds);
|
pipe(fds);
|
||||||
str = redir->word.word;
|
str = redir->word;
|
||||||
write(fds[PIPE_WRITE], str, ft_strlen(str));
|
write(fds[PIPE_WRITE], str, ft_strlen(str));
|
||||||
close(fds[PIPE_WRITE]);
|
close(fds[PIPE_WRITE]);
|
||||||
dup2(fds[PIPE_READ], 0);
|
dup2(fds[PIPE_READ], 0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/06 22:03:53 by jhalford #+# #+# */
|
/* Created: 2017/02/06 22:03:53 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/02/06 22:42:05 by jhalford ### ########.fr */
|
/* Updated: 2017/03/05 18:07:25 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ int redirect_great(t_redir* redir)
|
||||||
int fdnew;
|
int fdnew;
|
||||||
|
|
||||||
fdnew = redir->n;
|
fdnew = redir->n;
|
||||||
if ((fdold = open(redir->word.word,
|
if ((fdold = open(redir->word,
|
||||||
O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0)
|
O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0)
|
||||||
{
|
{
|
||||||
DG("open errno=%i", errno);
|
DG("open errno=%i", errno);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/06 22:12:31 by jhalford #+# #+# */
|
/* Created: 2017/02/06 22:12:31 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/02/07 17:54:40 by jhalford ### ########.fr */
|
/* Updated: 2017/03/05 18:12:26 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,7 +17,11 @@ int redirect_greatand(t_redir *redir)
|
||||||
int fdold;
|
int fdold;
|
||||||
int fdnew;
|
int fdnew;
|
||||||
|
|
||||||
|
(void)redir;
|
||||||
|
(void)fdold;
|
||||||
|
(void)fdnew;
|
||||||
DG("redir greatand");
|
DG("redir greatand");
|
||||||
|
/*
|
||||||
if (redir->close)
|
if (redir->close)
|
||||||
{
|
{
|
||||||
close(redir->n);
|
close(redir->n);
|
||||||
|
|
@ -33,5 +37,6 @@ int redirect_greatand(t_redir *redir)
|
||||||
dup2_close(fdold, fdnew);
|
dup2_close(fdold, fdnew);
|
||||||
else
|
else
|
||||||
return (bad_fd(fdold));
|
return (bad_fd(fdold));
|
||||||
|
*/
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */
|
/* Created: 2017/02/06 22:09:53 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/02/20 20:42:53 by ariard ### ########.fr */
|
/* Updated: 2017/03/05 18:11:13 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -18,10 +18,10 @@ int redirect_less(t_redir *redir)
|
||||||
int fdnew;
|
int fdnew;
|
||||||
|
|
||||||
fdnew = redir->n;
|
fdnew = redir->n;
|
||||||
if ((fdold = open(redir->word.word, O_RDONLY)) < 0)
|
if ((fdold = open(redir->word, O_RDONLY)) < 0)
|
||||||
{
|
{
|
||||||
ft_dprintf(2, "{red}%s: no such file or directory: %s{eoc}\n",
|
ft_dprintf(2, "{red}%s: no such file or directory: %s{eoc}\n",
|
||||||
SHELL_NAME, redir->word.word);
|
SHELL_NAME, redir->word);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
dup2(fdold, fdnew);
|
dup2(fdold, fdnew);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/06 22:11:18 by jhalford #+# #+# */
|
/* Created: 2017/02/06 22:11:18 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/02/07 17:54:57 by jhalford ### ########.fr */
|
/* Updated: 2017/03/05 18:13:11 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,6 +17,10 @@ int redirect_lessand(t_redir *redir)
|
||||||
int fdold;
|
int fdold;
|
||||||
int fdnew;
|
int fdnew;
|
||||||
|
|
||||||
|
(void)redir;
|
||||||
|
(void)fdold;
|
||||||
|
(void)fdnew;
|
||||||
|
/*
|
||||||
if (redir->close)
|
if (redir->close)
|
||||||
{
|
{
|
||||||
close(redir->n);
|
close(redir->n);
|
||||||
|
|
@ -35,5 +39,6 @@ int redirect_lessand(t_redir *redir)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return (bad_fd(fdold));
|
return (bad_fd(fdold));
|
||||||
|
*/
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 11:58:44 by jhalford #+# #+# */
|
/* Created: 2016/12/03 11:58:44 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/02/25 19:56:31 by ariard ### ########.fr */
|
/* Updated: 2017/03/05 17:08:23 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/09 17:08:51 by jhalford #+# #+# */
|
/* Created: 2017/02/09 17:08:51 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/05 18:42:43 by wescande ### ########.fr */
|
/* Updated: 2017/03/05 19:30:00 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:06:45 by jhalford #+# #+# */
|
/* Created: 2016/12/03 12:06:45 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/05 17:15:52 by wescande ### ########.fr */
|
/* Updated: 2017/03/05 18:03:34 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -48,35 +48,3 @@ int lexer_number(t_list **alst, t_lexer *lexer)
|
||||||
return (lexer_lex(alst, lexer));
|
return (lexer_lex(alst, lexer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
int lexer_number(t_list **alst, t_lexer *lexer)
|
|
||||||
{
|
|
||||||
t_token *token;
|
|
||||||
t_lexstate state;
|
|
||||||
|
|
||||||
token = (*alst)->content;
|
|
||||||
token->type = TK_IO_NUMBER;
|
|
||||||
if ((state = get_state_global(lexer))
|
|
||||||
|| (state = get_state_redir(lexer)))
|
|
||||||
{
|
|
||||||
lexer->state = state;
|
|
||||||
return (lexer_lex(alst, lexer));
|
|
||||||
}
|
|
||||||
else if (ft_isdigit(lexer->str[lexer->pos])
|
|
||||||
&& (lexer->str[lexer->pos + 1] == '>' || lexer->str[lexer->pos + 1] == '<'))
|
|
||||||
{
|
|
||||||
token_append(token, lexer, 0, 0);
|
|
||||||
lexer->pos++;
|
|
||||||
return (lexer_number(alst, lexer));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
token->type = TK_WORD;
|
|
||||||
token_append(token, lexer, 0, 0);
|
|
||||||
lexer->pos++;
|
|
||||||
return (lexer_lex(alst, lexer));
|
|
||||||
}
|
|
||||||
lexer->state = DEFAULT;
|
|
||||||
return (lexer_lex(alst, lexer));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/03 17:37:15 by jhalford #+# #+# */
|
/* Created: 2017/03/03 17:37:15 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/05 16:29:28 by jhalford ### ########.fr */
|
/* Updated: 2017/03/05 16:48:06 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:07:11 by jhalford #+# #+# */
|
/* Created: 2016/12/03 12:07:11 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/03 17:56:07 by jhalford ### ########.fr */
|
/* Updated: 2017/03/05 17:07:26 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/03 20:05:54 by ariard ### ########.fr */
|
/* Updated: 2017/03/05 14:57:19 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,6 +17,8 @@ char *ft_putast(void *nodein)
|
||||||
t_astnode *node;
|
t_astnode *node;
|
||||||
node = nodein;
|
node = nodein;
|
||||||
|
|
||||||
|
if (node->type == WORDLIST)
|
||||||
|
return ("WORDLIST");
|
||||||
if (node->type == CMD)
|
if (node->type == CMD)
|
||||||
return ("CMD");
|
return ("CMD");
|
||||||
if (node->type == REDIR)
|
if (node->type == REDIR)
|
||||||
|
|
|
||||||
|
|
@ -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/05 16:32:36 by jhalford ### ########.fr */
|
/* Updated: 2017/03/05 16:47:43 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/05 15:33:58 by wescande ### ########.fr */
|
/* Updated: 2017/03/05 17:30:19 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/04 22:05:47 by ariard ### ########.fr */
|
/* Updated: 2017/03/05 16:34:17 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -36,7 +36,6 @@ int superflous_token(t_btree **ast, t_list **lst)
|
||||||
t_token *token;
|
t_token *token;
|
||||||
|
|
||||||
(void)ast;
|
(void)ast;
|
||||||
DG("superflous token");
|
|
||||||
if (*lst)
|
if (*lst)
|
||||||
{
|
{
|
||||||
token = (*lst)->content;
|
token = (*lst)->content;
|
||||||
|
|
@ -73,7 +72,6 @@ int add_cmd(t_btree **ast, t_list **lst)
|
||||||
DG("add cmd");
|
DG("add cmd");
|
||||||
while (i < 14)
|
while (i < 14)
|
||||||
{
|
{
|
||||||
DG("test");
|
|
||||||
if (g_distrostree[i].test(ast, lst) == 1)
|
if (g_distrostree[i].test(ast, lst) == 1)
|
||||||
{
|
{
|
||||||
DG("add : %d", i);
|
DG("add : %d", i);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* 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/05 15:33:35 by wescande ### ########.fr */
|
/* Updated: 2017/03/05 16:46:50 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ 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_WORD
|
if (node->type == TK_FOR && (token->type == TK_WORD || token->type == TK_NAME)
|
||||||
&& node->pattern == 0)
|
&& node->pattern == 0)
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +94,8 @@ int add_loop_condition(t_btree **ast, t_list **lst)
|
||||||
|
|
||||||
token = (*lst)->content;
|
token = (*lst)->content;
|
||||||
node = (*ast)->item;
|
node = (*ast)->item;
|
||||||
ft_lsteadd(&node->data.wordlist, ft_lstnew(ft_strdup(token->data),
|
DG("add word");
|
||||||
|
ft_lsteadd(&node->data.cmd.wordlist, ft_lstnew(ft_strdup(token->data),
|
||||||
ft_strlen(token->data)));
|
ft_strlen(token->data)));
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
40
42sh/src/parser/add_number.c
Normal file
40
42sh/src/parser/add_number.c
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* add_number.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/05 17:28:31 by ariard #+# #+# */
|
||||||
|
/* Updated: 2017/03/05 18:15:40 by ariard ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
|
int isionumber(t_btree **ast, t_list **lst)
|
||||||
|
{
|
||||||
|
t_token *token;
|
||||||
|
|
||||||
|
(void)ast;
|
||||||
|
token = (*lst)->content;
|
||||||
|
if (token->type == TK_IO_NUMBER)
|
||||||
|
return (1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int add_ionumber(t_btree **ast, t_list **lst)
|
||||||
|
{
|
||||||
|
t_astnode *node;
|
||||||
|
t_token *token;
|
||||||
|
t_redir redir;
|
||||||
|
|
||||||
|
if (!*ast)
|
||||||
|
gen_node(ast);
|
||||||
|
token = (*lst)->content;
|
||||||
|
node = (*ast)->item;
|
||||||
|
node->type = token->type;
|
||||||
|
redir.n = ft_atoi(token->data);
|
||||||
|
ft_lsteadd(&node->data.cmd.redir, ft_lstnew(&redir, sizeof(redir)));
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
@ -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/04 20:00:46 by ariard ### ########.fr */
|
/* Updated: 2017/03/05 18:14:00 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,26 +14,14 @@
|
||||||
|
|
||||||
int isdir_sep(t_btree **ast, t_list **list)
|
int isdir_sep(t_btree **ast, t_list **list)
|
||||||
{
|
{
|
||||||
t_astnode *node;
|
|
||||||
t_token *token;
|
t_token *token;
|
||||||
|
|
||||||
|
(void)ast;
|
||||||
token = (*list)->content;
|
token = (*list)->content;
|
||||||
if (*ast)
|
if (token->type == TK_LESS || token->type == TK_GREAT
|
||||||
{
|
|| token->type == TK_GREATAND || token->type == TK_LESSAND
|
||||||
node = (*ast)->item;
|
|| token->type == TK_DLESS || token->type == TK_DGREAT)
|
||||||
if (node->type == CMD
|
return (1);
|
||||||
&& (token->type == TK_LESS || token->type == TK_GREAT
|
|
||||||
|| token->type == TK_GREATAND || token->type == TK_LESSAND
|
|
||||||
|| token->type == TK_DLESS || token->type == TK_DGREAT))
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (!*ast)
|
|
||||||
{
|
|
||||||
if (token->type == TK_LESS || token->type == TK_GREAT
|
|
||||||
|| token->type == TK_GREATAND || token->type == TK_LESSAND
|
|
||||||
|| token->type == TK_DLESS || token->type == TK_DGREAT)
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,7 +35,10 @@ int isdir_word(t_btree **ast, t_list **list)
|
||||||
{
|
{
|
||||||
node = (*ast)->item;
|
node = (*ast)->item;
|
||||||
if (token->type == TK_WORD && node->type == REDIR)
|
if (token->type == TK_WORD && node->type == REDIR)
|
||||||
return ((node->type = CMD));
|
{
|
||||||
|
node->type = CMD;
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
@ -65,11 +56,9 @@ int add_redir_word(t_btree **ast, t_list **lst)
|
||||||
DG("add file");
|
DG("add file");
|
||||||
redir = (ft_lstlast(node->data.cmd.redir))->content;
|
redir = (ft_lstlast(node->data.cmd.redir))->content;
|
||||||
if (redir->type == TK_DLESS)
|
if (redir->type == TK_DLESS)
|
||||||
redir->word.word = NULL;
|
redir->word = NULL;
|
||||||
else if (ft_stris((char *)token->data, &ft_isdigit))
|
|
||||||
redir->word.fd = ft_atoi(token->data);
|
|
||||||
else
|
else
|
||||||
redir->word.word = ft_strdup(token->data);
|
redir->word = ft_strdup(token->data);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
@ -80,13 +69,17 @@ int add_redir_type(t_btree **ast, t_list **lst)
|
||||||
t_token *token;
|
t_token *token;
|
||||||
t_redir redir;
|
t_redir redir;
|
||||||
|
|
||||||
DG("add redir");
|
|
||||||
if (!*ast)
|
if (!*ast)
|
||||||
gen_node(ast);
|
gen_node(ast);
|
||||||
token = (*lst)->content;
|
token = (*lst)->content;
|
||||||
node = (*ast)->item;
|
node = (*ast)->item;
|
||||||
|
if (!(node->type == TK_IO_NUMBER))
|
||||||
|
{
|
||||||
|
redir.n = (token->type == TK_LESS || token->type == TK_DLESS
|
||||||
|
|| token->type == TK_LESSAND) ? STDIN : STDOUT;
|
||||||
|
ft_lsteadd(&node->data.cmd.redir, ft_lstnew(&redir, sizeof(redir)));
|
||||||
|
}
|
||||||
node->type = REDIR;
|
node->type = REDIR;
|
||||||
redir.type = token->type;
|
redir.type = token->type;
|
||||||
ft_lsteadd(&node->data.cmd.redir, ft_lstnew(&redir, sizeof(redir)));
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */ /* */
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* aggregate_sym.c :+: :+: :+: */
|
/* aggregate_sym.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
|
|
@ -316,21 +315,21 @@ int aggregate_sym(t_list **stack, t_sym *new_sym, t_parstate *state)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
head = (*stack)->content;
|
head = (*stack)->content;
|
||||||
DG("aggregate head %s && sym %s",
|
// DG("aggregate head %s && sym %s",
|
||||||
read_state(*head), read_state(*new_sym));
|
// read_state(*head), read_state(*new_sym));
|
||||||
while (g_aggrematch[i].top)
|
while (g_aggrematch[i].top)
|
||||||
{
|
{
|
||||||
if (*new_sym == g_aggrematch[i].top
|
if (*new_sym == g_aggrematch[i].top
|
||||||
&& MATCH_STACK(*head, g_aggrematch[i].under))
|
&& MATCH_STACK(*head, g_aggrematch[i].under))
|
||||||
|
|
||||||
{
|
{
|
||||||
DG("MATCH : %s", read_state(g_aggrematch[i].new_sym));
|
// DG("MATCH : %s", read_state(g_aggrematch[i].new_sym));
|
||||||
*new_sym = g_aggrematch[i].new_sym;
|
*new_sym = g_aggrematch[i].new_sym;
|
||||||
if (g_aggrematch[i].erase_sym)
|
if (g_aggrematch[i].erase_sym)
|
||||||
{
|
{
|
||||||
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))
|
||||||
return ((*state = ERROR));
|
return ((*state = ERROR));
|
||||||
|
|
|
||||||
|
|
@ -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/04 20:56:42 by ariard ### ########.fr */
|
/* Updated: 2017/03/05 15:04:14 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -41,6 +41,7 @@ t_treematch g_treematch[] =
|
||||||
{TK_PAREN_OPEN, &add_cmd},
|
{TK_PAREN_OPEN, &add_cmd},
|
||||||
{TK_PAREN_CLOSE, &add_cmd},
|
{TK_PAREN_CLOSE, &add_cmd},
|
||||||
{TK_FOR, &add_cmd},
|
{TK_FOR, &add_cmd},
|
||||||
|
{TK_NAME, &add_cmd},
|
||||||
{TK_ASSIGNEMENT_WORD, &add_cmd},
|
{TK_ASSIGNEMENT_WORD, &add_cmd},
|
||||||
{SUBSHELL, &add_cmd},
|
{SUBSHELL, &add_cmd},
|
||||||
{TK_LBRACE, &add_cmd},
|
{TK_LBRACE, &add_cmd},
|
||||||
|
|
|
||||||
|
|
@ -1027,7 +1027,7 @@ int eval_sym(t_list **stack, t_sym new_sym)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
head = (*stack)->content;
|
head = (*stack)->content;
|
||||||
DG("eval head %s && sym %s", read_state(*head), read_state(new_sym));
|
// DG("eval head %s && sym %s", read_state(*head), read_state(new_sym));
|
||||||
i = 0;
|
i = 0;
|
||||||
while (g_stackmatch[i].top)
|
while (g_stackmatch[i].top)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,9 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser)
|
||||||
while (*token)
|
while (*token)
|
||||||
{
|
{
|
||||||
produce_sym(&parser->stack, parser->new_sym, token);
|
produce_sym(&parser->stack, parser->new_sym, token);
|
||||||
DG("new sym %s", read_state(*parser->new_sym));
|
// DG("new sym %s", read_state(*parser->new_sym));
|
||||||
if (eval_sym(&parser->stack, *parser->new_sym))
|
if (eval_sym(&parser->stack, *parser->new_sym))
|
||||||
{
|
|
||||||
DG("ERRROR");
|
|
||||||
return ((parser->state = ERROR));
|
return ((parser->state = ERROR));
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
aggregate_sym(&parser->stack, parser->new_sym, &parser->state);
|
aggregate_sym(&parser->stack, parser->new_sym, &parser->state);
|
||||||
|
|
@ -55,7 +52,7 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser)
|
||||||
else
|
else
|
||||||
parser->state = UNDEFINED;
|
parser->state = UNDEFINED;
|
||||||
build_tree(ast, token);
|
build_tree(ast, token);
|
||||||
// btree_print(STDBUG, *ast, &ft_putast);
|
btree_print(STDBUG, *ast, &ft_putast);
|
||||||
if ((end_instruction(&parser->stack) && !(*token)->next))
|
if ((end_instruction(&parser->stack) && !(*token)->next))
|
||||||
insert_linebreak(token);
|
insert_linebreak(token);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/09 19:12:44 by ariard #+# #+# */
|
/* Created: 2017/02/09 19:12:44 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/03 14:28:02 by ariard ### ########.fr */
|
/* Updated: 2017/03/05 16:28:52 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,7 +17,6 @@ int pop_stack(t_list **stack, t_sym erase_sym)
|
||||||
t_sym *head;
|
t_sym *head;
|
||||||
t_list *temp;
|
t_list *temp;
|
||||||
|
|
||||||
DG("pop until :%s", read_state(erase_sym));
|
|
||||||
head = (*stack)->content;
|
head = (*stack)->content;
|
||||||
while ((*stack) && *head != erase_sym)
|
while ((*stack) && *head != erase_sym)
|
||||||
{
|
{
|
||||||
|
|
@ -29,12 +28,5 @@ int pop_stack(t_list **stack, t_sym erase_sym)
|
||||||
temp = *stack;
|
temp = *stack;
|
||||||
(*stack) = (*stack)->next;
|
(*stack) = (*stack)->next;
|
||||||
ft_lstdelone(&temp, NULL);
|
ft_lstdelone(&temp, NULL);
|
||||||
/*
|
return (0);
|
||||||
DG("pop until :%s", read_state(erase_sym));
|
|
||||||
temp = *stack;
|
|
||||||
while (*temp != erase_sym)
|
|
||||||
*temp-- = 0;
|
|
||||||
*temp-- = 0;
|
|
||||||
*stack = temp;
|
|
||||||
*/ return (0);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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/03 18:43:13 by ariard ### ########.fr */
|
/* Updated: 2017/03/05 15:12:59 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -107,8 +107,8 @@ int produce_sym(t_list **stack, t_sym *new_sym, t_list **lst)
|
||||||
|
|
||||||
token = (*lst)->content;
|
token = (*lst)->content;
|
||||||
head = (*stack)->content;
|
head = (*stack)->content;
|
||||||
DG("produce stack : %s && token : %s", read_state(*head),
|
// DG("produce stack : %s && token : %s", read_state(*head),
|
||||||
read_state(token->type));
|
// read_state(token->type));
|
||||||
i = 0;
|
i = 0;
|
||||||
*new_sym = 0;
|
*new_sym = 0;
|
||||||
while (g_prodmatch[i].new_sym)
|
while (g_prodmatch[i].new_sym)
|
||||||
|
|
@ -116,7 +116,7 @@ int produce_sym(t_list **stack, t_sym *new_sym, t_list **lst)
|
||||||
if (token->type == g_prodmatch[i].token
|
if (token->type == g_prodmatch[i].token
|
||||||
&& *head == g_prodmatch[i].stack)
|
&& *head == g_prodmatch[i].stack)
|
||||||
{
|
{
|
||||||
DG("MATCH : %s", read_state(g_prodmatch[i].new_sym));
|
// DG("MATCH : %s", read_state(g_prodmatch[i].new_sym));
|
||||||
*new_sym = g_prodmatch[i].new_sym;
|
*new_sym = g_prodmatch[i].new_sym;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
|
||||||
|
|
@ -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/04 21:20:16 by ariard ### ########.fr */
|
/* Updated: 2017/03/05 16:56:00 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -29,7 +29,7 @@ int gen_node(t_btree **ast)
|
||||||
ft_bzero((void *)&((t_astnode *)(*ast)->item)->data, sizeof(t_astdata));
|
ft_bzero((void *)&((t_astnode *)(*ast)->item)->data, sizeof(t_astdata));
|
||||||
((t_astnode *)(*ast)->item)->nest = 0;
|
((t_astnode *)(*ast)->item)->nest = 0;
|
||||||
((t_astnode *)(*ast)->item)->full = 0;
|
((t_astnode *)(*ast)->item)->full = 0;
|
||||||
((t_astnode *)(*ast)->item)->type = 0;
|
((t_astnode *)(*ast)->item)->type = TK_NEWLINE;
|
||||||
((t_astnode *)(*ast)->item)->pattern = 0;
|
((t_astnode *)(*ast)->item)->pattern = 0;
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue