end merge
This commit is contained in:
commit
ad3525b9d6
20 changed files with 66 additions and 88 deletions
|
|
@ -6,7 +6,7 @@
|
|||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
||||
# Updated: 2017/03/15 18:11:31 by jhalford ### ########.fr #
|
||||
# Updated: 2017/03/16 23:02:12 by jhalford ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/27 20:29:56 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/15 21:54:52 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/16 20:24:46 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 23:36:02 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/17 00:07:51 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -34,7 +34,6 @@ enum e_lexstate
|
|||
QUOTE,
|
||||
DQUOTE,
|
||||
BQUOTE,
|
||||
DQUOTE_BQUOTE,
|
||||
BACKSLASH,
|
||||
CURLY_BRACKETS,
|
||||
ASSIGNEMENT_WORD,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 22:18:45 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/16 23:01:59 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -32,34 +32,35 @@
|
|||
# include "completion.h"
|
||||
# include "hash.h"
|
||||
|
||||
#ifndef DEBUG
|
||||
# define DEBUG_MODE 0
|
||||
#else
|
||||
# define DEBUG_MODE 1
|
||||
#endif
|
||||
|
||||
struct s_data
|
||||
{
|
||||
t_flag opts;
|
||||
int fd;
|
||||
char **env;
|
||||
int argc;
|
||||
char **argv;
|
||||
t_line line;
|
||||
t_list *token;
|
||||
t_btree *ast;
|
||||
t_lexer lexer;
|
||||
t_parser parser;
|
||||
t_comp *comp;
|
||||
t_exec exec;
|
||||
t_jobc jobc;
|
||||
char **local_var;
|
||||
t_list *lst_func;
|
||||
t_flag opts;
|
||||
char **env;
|
||||
int argc;
|
||||
char **argv;
|
||||
t_line line;
|
||||
t_comp *comp;
|
||||
t_exec exec;
|
||||
t_jobc jobc;
|
||||
t_list *heredoc_queue;
|
||||
char **local_var;
|
||||
t_list *lst_func;
|
||||
};
|
||||
|
||||
int shell_init(int ac, char **av);
|
||||
void shell_exit(void);
|
||||
int data_init(int ac, char **av);
|
||||
void data_exit(void);
|
||||
int error_msg(char *msg);
|
||||
|
||||
int instruction_free(
|
||||
t_list **token, t_btree **ast, t_lexer *lexer, t_parser *parser);
|
||||
/* void content_free(void *data, size_t content_size); */
|
||||
int instruction_free(t_list **token, t_parser *parser,
|
||||
t_btree **ast);
|
||||
void content_free(void *data, size_t content_size);
|
||||
|
||||
char *ft_putast(void *node);
|
||||
void ft_putast2(void *node);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 18:17:16 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/17 00:06:21 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 15:47:30 by wescande #+# #+# */
|
||||
/* Updated: 2017/03/16 18:40:47 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/16 21:45:47 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 16:50:43 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/16 23:00:36 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ int mark_process_status(pid_t pid, int status)
|
|||
{
|
||||
p->attrs &= ~PROCESS_STATE_MASK;
|
||||
p->attrs |= PROCESS_COMPLETED;
|
||||
if (WIFSIGNALED(status))
|
||||
if (WIFSIGNALED(status) && DEBUG_MODE)
|
||||
ft_printf("{mag}%d: Terminated by signal %d.\n{eoc}",
|
||||
(int)pid, WTERMSIG(status));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/13 19:09:30 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 18:42:45 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/16 21:42:35 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/13 22:21:19 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 18:51:31 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/16 20:08:57 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 18:40:59 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/16 21:42:38 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/13 13:54:51 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 18:24:01 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/16 22:23:24 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/03 17:39:45 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/07 19:33:30 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/16 22:50:16 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/09 20:39:06 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 19:00:30 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/17 00:08:12 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/03 11:56:49 by jhalford #+# #+# */
|
||||
/* Updated: 2017/02/20 22:04:36 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/16 22:36:31 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/09 22:03:48 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/08 23:32:14 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/16 22:30:59 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,40 +15,25 @@
|
|||
int lexer_bquote(t_list **alst, t_lexer *lexer)
|
||||
{
|
||||
t_token *token;
|
||||
int top_state;
|
||||
int back;
|
||||
|
||||
token = (*alst)->content;
|
||||
token->type = TK_WORD;
|
||||
if (lexer->state == DQUOTE_BQUOTE)
|
||||
token_append(token, lexer, 1, 0);
|
||||
else
|
||||
token_append(token, lexer, 0, 0);
|
||||
back = 0;
|
||||
if (lexer->str[lexer->pos] == '`')
|
||||
{
|
||||
lexer->pos++;
|
||||
if (!(lexer->stack && (*(int*)lexer->stack->content == BQUOTE
|
||||
|| *(int*)lexer->stack->content == DQUOTE_BQUOTE)))
|
||||
{
|
||||
if (get_lexer_stack(*lexer) != BQUOTE)
|
||||
push(&lexer->stack, lexer->state);
|
||||
return (lexer_lex(alst, lexer));
|
||||
}
|
||||
top_state = pop(&lexer->stack);
|
||||
lexer->state = top_state == DQUOTE_BQUOTE ? DQUOTE : DEFAULT;
|
||||
return (lexer_lex(alst, lexer));
|
||||
else
|
||||
lexer->state = pop(&lexer->stack) == DQUOTE ? DQUOTE : DEFAULT;
|
||||
}
|
||||
if (lexer->str[lexer->pos] == '\\')
|
||||
else if (lexer->str[lexer->pos] == '\\' && (back = 1))
|
||||
{
|
||||
lexer->pos++;
|
||||
if (lexer->str[lexer->pos] == 0)
|
||||
{
|
||||
push(&lexer->stack, BACKSLASH);
|
||||
return (0);
|
||||
}
|
||||
else
|
||||
token_append(token, lexer, 1, 1);
|
||||
lexer->pos++;
|
||||
return (lexer_lex(alst,lexer));
|
||||
return (push(&lexer->stack, BACKSLASH) ? 0 : 0);
|
||||
}
|
||||
token_append(token, lexer, back, back);
|
||||
lexer->pos++;
|
||||
return (lexer_lex(alst, lexer));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 18:36:21 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 19:05:25 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/16 21:42:47 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,11 +17,15 @@ int lexer_default(t_list **alst, t_lexer *lexer)
|
|||
t_token *token;
|
||||
char c;
|
||||
|
||||
c = lexer->str[lexer->pos];
|
||||
c = lexer->str[lexer->pos];
|
||||
if ((lexer->state = get_state_global(lexer)))
|
||||
{
|
||||
DG("got state %i",lexer->state);
|
||||
return (lexer_lex(alst, lexer));
|
||||
}
|
||||
if ((lexer->state = get_state_redir(lexer)))
|
||||
return (lexer_lex(alst, lexer));
|
||||
DG("no special state, %c",lexer->str[lexer->pos]);
|
||||
lexer->state = ft_isdigit(c) ? NUMBER : WORD;
|
||||
token = (*alst)->content;
|
||||
token->type = TK_WORD;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 18:36:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/05 17:09:20 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/16 22:59:52 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -20,32 +20,21 @@ int lexer_dquote(t_list **alst, t_lexer *lexer)
|
|||
token->type = TK_WORD;
|
||||
if (lexer->str[lexer->pos] == '"')
|
||||
{
|
||||
lexer->pos++;
|
||||
if (!(lexer->stack && *(int*)lexer->stack->content == DQUOTE))
|
||||
{
|
||||
push(&lexer->stack, DQUOTE);
|
||||
return (lexer_lex(alst, lexer));
|
||||
}
|
||||
lexer->state = WORD;
|
||||
pop(&lexer->stack);
|
||||
return (lexer_lex(alst, lexer));
|
||||
}
|
||||
if (lexer->str[lexer->pos] == '\\')
|
||||
{
|
||||
lexer->pos++;
|
||||
if (lexer->str[lexer->pos] == 0)
|
||||
return (0);
|
||||
if (get_lexer_stack(*lexer) == DQUOTE && (lexer->state = WORD))
|
||||
pop(&lexer->stack);
|
||||
else
|
||||
token_append(token, lexer, 1, 1);
|
||||
lexer->pos++;
|
||||
return (lexer_lex(alst,lexer));
|
||||
push(&lexer->stack, DQUOTE);
|
||||
}
|
||||
else if (lexer->str[lexer->pos] == '`')
|
||||
else if (lexer->str[lexer->pos] == '\\')
|
||||
{
|
||||
lexer->state = DQUOTE_BQUOTE;
|
||||
return (lexer_bquote(alst, lexer));
|
||||
if (lexer->str[lexer->pos + 1] == 0)
|
||||
return(lexer_backslash(alst, lexer));
|
||||
token_append(token, lexer, 1, 1);
|
||||
}
|
||||
token_append(token, lexer, 1, 0);
|
||||
else if (lexer->str[lexer->pos] == '`' && (lexer->state = BQUOTE))
|
||||
return (lexer_lex(alst, lexer));
|
||||
else
|
||||
token_append(token, lexer, 1, 0);
|
||||
lexer->pos++;
|
||||
return (lexer_lex(alst, lexer));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/05 16:58:24 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 14:44:51 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/16 23:17:09 by jhalford ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,7 +17,8 @@ int lexer_end(t_list **alst, t_lexer *lexer)
|
|||
t_token *token;
|
||||
|
||||
if (lexer->str[lexer->pos] == '#')
|
||||
while (lexer->str[++lexer->pos]);
|
||||
while (lexer->str[++lexer->pos])
|
||||
;
|
||||
if (*alst && (lexer->state == QUOTE
|
||||
|| lexer->state == DQUOTE
|
||||
|| lexer->state == BQUOTE))
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/09 17:08:51 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/17 00:09:05 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -26,7 +27,6 @@ int (*g_lexer[])(t_list **alst, t_lexer *lexer) =
|
|||
&lexer_quote,
|
||||
&lexer_dquote,
|
||||
&lexer_bquote,
|
||||
&lexer_bquote,
|
||||
&lexer_backslash,
|
||||
&lexer_curly_braces,
|
||||
&lexer_assignement_word,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/16 23:38:05 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue