resolution empty tree + nested loop + while error lexing
This commit is contained in:
parent
0dc029406f
commit
73b4cc3060
26 changed files with 153 additions and 53 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/30 22:32:57 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 19:34:10 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -73,6 +73,8 @@ extern t_execmap g_execmap[];
|
||||||
|
|
||||||
int ft_exec(t_btree **ast);
|
int ft_exec(t_btree **ast);
|
||||||
|
|
||||||
|
int exec_default(t_btree **ast);
|
||||||
|
|
||||||
int exec_semi(t_btree **ast);
|
int exec_semi(t_btree **ast);
|
||||||
int exec_ampersand(t_btree **ast);
|
int exec_ampersand(t_btree **ast);
|
||||||
int exec_or_if(t_btree **ast);
|
int exec_or_if(t_btree **ast);
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,20 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
|
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/30 23:41:17 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 21:55:48 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef LEXER_H
|
#ifndef LEXER_H
|
||||||
# define LEXER_H
|
# define LEXER_H
|
||||||
|
|
||||||
|
struct s_nest
|
||||||
|
{
|
||||||
|
long long do_group;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct s_nest t_nest;
|
||||||
|
|
||||||
# include "minishell.h"
|
# include "minishell.h"
|
||||||
|
|
||||||
typedef long long t_type;
|
typedef long long t_type;
|
||||||
|
|
@ -64,7 +71,8 @@ enum e_lexstate
|
||||||
VAR,
|
VAR,
|
||||||
SPECIAL,
|
SPECIAL,
|
||||||
WHILE,
|
WHILE,
|
||||||
DO_GROUP,
|
DO,
|
||||||
|
DONE,
|
||||||
LIST,
|
LIST,
|
||||||
COMMENT,
|
COMMENT,
|
||||||
};
|
};
|
||||||
|
|
@ -116,7 +124,8 @@ int lexer_backslash(t_list **alst, char *str);
|
||||||
int lexer_var(t_list **alst, char *str);
|
int lexer_var(t_list **alst, char *str);
|
||||||
int lexer_special(t_list **alst, char *str);
|
int lexer_special(t_list **alst, char *str);
|
||||||
int lexer_while(t_list **alst, char *str);
|
int lexer_while(t_list **alst, char *str);
|
||||||
int lexer_do_group(t_list **alst, char *str);
|
int lexer_do(t_list **alst, char *str);
|
||||||
|
int lexer_done(t_list **alst, char *str);
|
||||||
int lexer_list(t_list **alst, char *str);
|
int lexer_list(t_list **alst, char *str);
|
||||||
int lexer_comment(t_list **alst, char *str);
|
int lexer_comment(t_list **alst, char *str);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/30 23:10:05 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 21:59:25 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -66,6 +66,7 @@ struct s_data
|
||||||
t_exec exec;
|
t_exec exec;
|
||||||
t_jobc jobc;
|
t_jobc jobc;
|
||||||
t_script script;
|
t_script script;
|
||||||
|
t_nest nest;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern t_stof g_builtins[];
|
extern t_stof g_builtins[];
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/01 12:15:54 by jhalford #+# #+# */
|
/* Created: 2016/12/01 12:15:54 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/30 18:52:54 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 19:31:01 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -58,6 +58,7 @@ struct s_astnode
|
||||||
extern t_parser g_parser[];
|
extern t_parser g_parser[];
|
||||||
|
|
||||||
int ft_parse(t_list **list_ast, t_btree **ast, t_list **token);
|
int ft_parse(t_list **list_ast, t_btree **ast, t_list **token);
|
||||||
|
|
||||||
int parse_newline(t_list **list_ast, t_btree **ast,
|
int parse_newline(t_list **list_ast, t_btree **ast,
|
||||||
t_list **start, t_list **lst);
|
t_list **start, t_list **lst);
|
||||||
int parse_separator(t_list **list_ast, t_btree **ast,
|
int parse_separator(t_list **list_ast, t_btree **ast,
|
||||||
|
|
@ -88,4 +89,5 @@ int parse_done(t_list **list_ast, t_btree **ast,
|
||||||
t_list **start, t_list **lst);
|
t_list **start, t_list **lst);
|
||||||
int parse_list(t_list **list_ast, t_btree **ast,
|
int parse_list(t_list **list_ast, t_btree **ast,
|
||||||
t_list **start, t_list **lst);
|
t_list **start, t_list **lst);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,2 @@
|
||||||
ls | wc -l > file1
|
ls | cat
|
||||||
cd ; pwd | wc -l ; echo "bonjour"
|
|
||||||
ls -l > file2
|
|
||||||
pwd ; echo "hello world"
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,20 @@
|
||||||
echo "begin script"
|
echo "begin loop"
|
||||||
while [ 1 ]
|
while [ 1 ]
|
||||||
do sleep 1 ; echo "hello 42sh"
|
do
|
||||||
|
echo "inner loop1"
|
||||||
|
while [ 1 ]
|
||||||
|
do
|
||||||
|
echo "love 42"
|
||||||
|
done
|
||||||
|
echo "inner loop2"
|
||||||
|
while [ 1 ]
|
||||||
|
do
|
||||||
|
echo "inner loop2-1"
|
||||||
|
while [ 1 ]
|
||||||
|
do
|
||||||
|
echo "hello world"
|
||||||
|
done
|
||||||
|
echo "salut monde"
|
||||||
|
done
|
||||||
done
|
done
|
||||||
echo "end script"
|
echo "end loop"
|
||||||
|
|
|
||||||
|
|
@ -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/01/11 17:50:03 by jhalford ### ########.fr */
|
/* Updated: 2017/01/31 18:49:37 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
23
42sh/src/exec/exec_default.c
Normal file
23
42sh/src/exec/exec_default.c
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* exec_default.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/01/31 19:29:59 by ariard #+# #+# */
|
||||||
|
/* Updated: 2017/01/31 19:57:44 by ariard ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "exec.h"
|
||||||
|
|
||||||
|
int exec_default(t_btree **ast)
|
||||||
|
{
|
||||||
|
t_process *p;
|
||||||
|
|
||||||
|
p = &data_singleton()->exec.process;
|
||||||
|
if (!(p->script & SCRIPT_LOOP))
|
||||||
|
btree_delone(ast, &ast_free);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/30 20:52:05 by jhalford #+# #+# */
|
/* Created: 2016/11/30 20:52:05 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/30 23:25:33 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 19:31:59 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/30 17:33:53 by ariard #+# #+# */
|
/* Created: 2017/01/30 17:33:53 by ariard #+# #+# */
|
||||||
/* Updated: 2017/01/30 23:41:55 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 20:45:41 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/01/30 23:15:15 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 20:00:23 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
t_execmap g_execmap[] =
|
t_execmap g_execmap[] =
|
||||||
{
|
{
|
||||||
|
{TK_NEWLINE, &exec_default},
|
||||||
{TK_AND_IF, &exec_and_if},
|
{TK_AND_IF, &exec_and_if},
|
||||||
{TK_OR_IF, &exec_or_if},
|
{TK_OR_IF, &exec_or_if},
|
||||||
{TK_SEMI, &exec_semi},
|
{TK_SEMI, &exec_semi},
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/30 21:02:10 by ariard #+# #+# */
|
/* Created: 2017/01/30 21:02:10 by ariard #+# #+# */
|
||||||
/* Updated: 2017/01/30 23:17:24 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 19:27:49 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */
|
/* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/27 12:50:21 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 21:08:54 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -30,7 +30,8 @@ int (*g_lexer[])(t_list **alst, char *str) =
|
||||||
&lexer_var,
|
&lexer_var,
|
||||||
&lexer_special,
|
&lexer_special,
|
||||||
&lexer_while,
|
&lexer_while,
|
||||||
&lexer_do_group,
|
&lexer_do,
|
||||||
|
&lexer_done,
|
||||||
&lexer_list,
|
&lexer_list,
|
||||||
&lexer_comment,
|
&lexer_comment,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/26 00:07:05 by ariard #+# #+# */
|
/* Created: 2017/01/26 00:07:05 by ariard #+# #+# */
|
||||||
/* Updated: 2017/01/26 18:47:52 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 21:11:47 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -16,8 +16,9 @@ t_lexstate get_reserved_words(char *str)
|
||||||
{
|
{
|
||||||
if (ft_strncmp(str, "while", 5) == 0)
|
if (ft_strncmp(str, "while", 5) == 0)
|
||||||
return (WHILE);
|
return (WHILE);
|
||||||
else if (ft_strncmp(str, "done", 4) == 0
|
else if (ft_strncmp(str, "done", 4) == 0 && ft_isalpha(*(str + 4)) == 0)
|
||||||
|| ft_strncmp(str, "do" , 2) == 0)
|
return (DONE);
|
||||||
return (DO_GROUP);
|
else if (ft_strncmp(str, "do" , 2) == 0 && ft_isalpha(*(str + 2)) == 0)
|
||||||
|
return (DO);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,25 +6,25 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/26 00:48:48 by ariard #+# #+# */
|
/* Created: 2017/01/26 00:48:48 by ariard #+# #+# */
|
||||||
/* Updated: 2017/01/26 18:49:32 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 21:57:33 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
|
|
||||||
int lexer_do_group(t_list **alst, char *str)
|
int lexer_do(t_list **alst, char *str)
|
||||||
{
|
{
|
||||||
t_token *token;
|
t_token *token;
|
||||||
t_lexstate state;
|
t_lexstate state;
|
||||||
int type;
|
t_nest *nest;
|
||||||
|
|
||||||
type = (str[0] == 'd' && str[1] == 'o' && str[2] != 'n' ?
|
nest = &data_singleton()->nest;
|
||||||
2 : 4);
|
|
||||||
if (*alst)
|
if (*alst)
|
||||||
{
|
{
|
||||||
if (ft_is_delim_list(*(str + type)) || *(str + type) == ' ')
|
nest->do_group++;
|
||||||
return (lexer_do_group(&(*alst)->next, str));
|
if (nest->do_group == 1)
|
||||||
return (ft_tokenize(alst, str + 1, LIST));
|
return (lexer_do(&(*alst)->next, str));
|
||||||
|
return (ft_tokenize(alst, str, LIST));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -32,7 +32,8 @@ int lexer_do_group(t_list **alst, char *str)
|
||||||
*alst = ft_lstnew(token, sizeof(*token));
|
*alst = ft_lstnew(token, sizeof(*token));
|
||||||
}
|
}
|
||||||
token = (*alst)->content;
|
token = (*alst)->content;
|
||||||
token->type = (type == 2 ? TK_DO : TK_DONE);
|
token->type = TK_DO;
|
||||||
state = (token->type == TK_DO) ? LIST : DEFAULT;
|
state = LIST;
|
||||||
return (ft_tokenize(&(*alst)->next, str + type, state));
|
// data_singleton()->scope |= (token->type == TK_DO) ? IN_LIST : OUT_LIST;
|
||||||
|
return (ft_tokenize(&(*alst)->next, str + 2, state));
|
||||||
}
|
}
|
||||||
39
42sh/src/lexer/lexer_done.c
Normal file
39
42sh/src/lexer/lexer_done.c
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* lexer_done.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/01/31 20:49:09 by ariard #+# #+# */
|
||||||
|
/* Updated: 2017/01/31 21:57:46 by ariard ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "lexer.h"
|
||||||
|
|
||||||
|
int lexer_done(t_list **alst, char *str)
|
||||||
|
{
|
||||||
|
t_token *token;
|
||||||
|
t_lexstate state;
|
||||||
|
t_nest *nest;
|
||||||
|
|
||||||
|
nest = &data_singleton()->nest;
|
||||||
|
if (*alst)
|
||||||
|
{
|
||||||
|
nest->do_group--;
|
||||||
|
if (nest->do_group == 0)
|
||||||
|
return (lexer_done(&(*alst)->next, str));
|
||||||
|
return (ft_tokenize(alst, str, LIST));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
token = token_init();
|
||||||
|
*alst = ft_lstnew(token, sizeof(*token));
|
||||||
|
}
|
||||||
|
token = (*alst)->content;
|
||||||
|
token->type = TK_DONE;
|
||||||
|
state = DEFAULT;
|
||||||
|
// data_singleton()->scope |= (token->type == TK_DO) ? IN_LIST : OUT_LIST;
|
||||||
|
return (ft_tokenize(&(*alst)->next, str + 4, state));
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/26 00:55:33 by ariard #+# #+# */
|
/* Created: 2017/01/26 00:55:33 by ariard #+# #+# */
|
||||||
/* Updated: 2017/01/30 23:14:45 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 22:05:36 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
int lexer_list(t_list **alst, char *str)
|
int lexer_list(t_list **alst, char *str)
|
||||||
{
|
{
|
||||||
t_token *token;
|
t_token *token;
|
||||||
char lim;
|
|
||||||
|
|
||||||
token = (*alst)->content;
|
token = (*alst)->content;
|
||||||
token->type = TK_LIST;
|
token->type = TK_LIST;
|
||||||
|
|
@ -23,14 +22,15 @@ int lexer_list(t_list **alst, char *str)
|
||||||
{
|
{
|
||||||
if (ft_is_delim_list(*str))
|
if (ft_is_delim_list(*str))
|
||||||
{
|
{
|
||||||
lim = *str++;
|
token_append(token, *str++);
|
||||||
while (ft_is_delim(*str) || *str == '\n')
|
while (ft_is_delim(*str) || *str == '\n')
|
||||||
str++;
|
str++;
|
||||||
if (ft_strncmp(str, "done", 4) == 0
|
if (ft_strncmp(str, "done", 4) == 0 && (ft_is_delim_list(*(str + 4))
|
||||||
|| ft_strncmp(str, "do", 2) == 0)
|
|| *(str + 4) == ' '))
|
||||||
return (ft_tokenize(alst, str, DO_GROUP));
|
return (ft_tokenize(alst, str, DONE));
|
||||||
else
|
else if (ft_strncmp(str, "do", 2) == 0 && (ft_is_delim_list(*(str + 2))
|
||||||
token_append(token, lim);
|
|| *(str + 2) == ' '))
|
||||||
|
return (ft_tokenize(alst, str, DO));
|
||||||
}
|
}
|
||||||
token_append(token, *str++);
|
token_append(token, *str++);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:07:30 by jhalford #+# #+# */
|
/* Created: 2016/12/03 12:07:30 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/26 22:25:08 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 18:41:48 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/23 22:37:43 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 21:50:31 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -24,6 +24,8 @@ int data_init(void)
|
||||||
data->env = ft_sstrdup(environ);
|
data->env = ft_sstrdup(environ);
|
||||||
data->opts = SHELL_OPTS_JOBC;
|
data->opts = SHELL_OPTS_JOBC;
|
||||||
|
|
||||||
|
data->nest.do_group = 0;
|
||||||
|
|
||||||
data->exec.process.path = NULL;
|
data->exec.process.path = NULL;
|
||||||
data->exec.process.av = NULL;
|
data->exec.process.av = NULL;
|
||||||
data->exec.process.fdin = STDIN;
|
data->exec.process.fdin = STDIN;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/30 20:45:01 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 21:25:39 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
/* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/23 22:35:46 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 20:02:04 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/22 23:06:34 by ariard #+# #+# */
|
/* Created: 2017/01/22 23:06:34 by ariard #+# #+# */
|
||||||
/* Updated: 2017/01/30 23:13:44 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 21:55:11 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */
|
/* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/30 17:14:19 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 18:38:01 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/30 16:36:28 by ariard #+# #+# */
|
/* Created: 2017/01/30 16:36:28 by ariard #+# #+# */
|
||||||
/* Updated: 2017/01/30 17:15:00 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 19:36:49 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/30 16:34:21 by ariard #+# #+# */
|
/* Created: 2017/01/30 16:34:21 by ariard #+# #+# */
|
||||||
/* Updated: 2017/01/30 23:38:15 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 20:20:13 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/26 19:26:41 by ariard #+# #+# */
|
/* Created: 2017/01/26 19:26:41 by ariard #+# #+# */
|
||||||
/* Updated: 2017/01/30 20:02:09 by ariard ### ########.fr */
|
/* Updated: 2017/01/31 19:35:54 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -16,7 +16,12 @@ int parse_newline(t_list **list_ast, t_btree **ast,
|
||||||
t_list **start, t_list **lst)
|
t_list **start, t_list **lst)
|
||||||
{
|
{
|
||||||
t_list *temp;
|
t_list *temp;
|
||||||
|
t_astnode *node;
|
||||||
|
t_token *token;
|
||||||
|
|
||||||
|
token = (*lst)->content;
|
||||||
|
node = (*ast)->item;
|
||||||
|
node->type = TK_NEWLINE;
|
||||||
temp = (*lst)->next;
|
temp = (*lst)->next;
|
||||||
(*lst)->next = NULL;
|
(*lst)->next = NULL;
|
||||||
ft_lst_delif(start, (*lst)->content, &ft_addrcmp, &token_free);
|
ft_lst_delif(start, (*lst)->content, &ft_addrcmp, &token_free);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue