merge
This commit is contained in:
commit
07934128f1
9 changed files with 35 additions and 25 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/14 22:59:57 by jhalford #+# #+# */
|
/* Created: 2017/03/14 22:59:57 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/20 23:22:19 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 17:28:02 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* 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/03/22 17:25:09 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 17:29:24 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,13 @@
|
||||||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/22 17:23:54 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 17:29:53 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#ifndef MINISHELL_H
|
#ifndef MINISHELL_H
|
||||||
# define MINISHELL_H
|
# define MINISHELL_H
|
||||||
|
|
||||||
# define SHELL_NAME "minishell"
|
# define SHELL_NAME "minishell"
|
||||||
|
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
/* parser.h :+: :+: :+: */
|
/* parser.h :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/01 12:15:54 by jhalford #+# #+# */
|
/* Created: 2017/03/22 17:22:51 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/03 18:18:14 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 17:25:11 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -82,11 +83,6 @@ int error_eof(void);
|
||||||
int ft_read_stack(t_sym *stack);
|
int ft_read_stack(t_sym *stack);
|
||||||
char *read_state(t_sym current);
|
char *read_state(t_sym current);
|
||||||
|
|
||||||
/*
|
|
||||||
* Build AST - rewriting
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct s_treematch
|
struct s_treematch
|
||||||
{
|
{
|
||||||
t_type type;
|
t_type type;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */
|
/* Created: 2016/12/13 17:11:48 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/22 17:22:52 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 17:30:06 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -196,6 +196,8 @@ enum e_sym
|
||||||
OPEN_FUNC,
|
OPEN_FUNC,
|
||||||
CLOSE_FUNC,
|
CLOSE_FUNC,
|
||||||
CLOSE_LIST,
|
CLOSE_LIST,
|
||||||
|
SEMI_SUBSHELL,
|
||||||
|
SEMI_BRACE,
|
||||||
REDIR,
|
REDIR,
|
||||||
CMD,
|
CMD,
|
||||||
HEREDOCDATA,
|
HEREDOCDATA,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
|
/* Created: 2017/03/20 14:45:40 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/22 17:35:21 by jhalford ### ########.fr */
|
/* Updated: 2017/03/22 17:37:32 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ static int handle_instruction(t_list **token, t_btree **ast)
|
||||||
return (ret);
|
return (ret);
|
||||||
if (do_lexer_routine(token, stream) > 0)
|
if (do_lexer_routine(token, stream) > 0)
|
||||||
continue ;
|
continue ;
|
||||||
/* token_print(*token); */
|
token_print(*token);
|
||||||
if ((ret = do_parser_routine(token, ast)) == 1
|
if ((ret = do_parser_routine(token, ast)) == 1
|
||||||
&& SH_NO_INTERACTIVE(data->opts))
|
&& SH_NO_INTERACTIVE(data->opts))
|
||||||
return (ret);
|
return (ret);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/11 15:58:38 by ariard #+# #+# */
|
/* Created: 2017/03/11 15:58:38 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/18 19:18:21 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:54:58 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -38,6 +38,7 @@ t_aggrematch g_aggrematch[] =
|
||||||
{TK_DONE, COMPOUND_LIST, DO_GROUP, TK_DO},
|
{TK_DONE, COMPOUND_LIST, DO_GROUP, TK_DO},
|
||||||
{TK_ESAC, TK_IN, CASE_CLAUSE, TK_CASE},
|
{TK_ESAC, TK_IN, CASE_CLAUSE, TK_CASE},
|
||||||
{TK_ESAC, CASE_LIST_NS, CASE_CLAUSE, TK_CASE},
|
{TK_ESAC, CASE_LIST_NS, CASE_CLAUSE, TK_CASE},
|
||||||
|
{TK_PAREN_CLOSE, SEMI_SUBSHELL, SUBSHELL, TK_PAREN_OPEN},
|
||||||
{TK_PAREN_CLOSE, COMPOUND_LIST, SUBSHELL, TK_PAREN_OPEN},
|
{TK_PAREN_CLOSE, COMPOUND_LIST, SUBSHELL, TK_PAREN_OPEN},
|
||||||
{TK_PAREN_CLOSE, CMD_SUPERIOR, SUBSHELL, TK_PAREN_OPEN},
|
{TK_PAREN_CLOSE, CMD_SUPERIOR, SUBSHELL, TK_PAREN_OPEN},
|
||||||
{TK_PAREN_CLOSE, PIPE_SEMI_SEQUENCE, SUBSHELL, TK_PAREN_OPEN},
|
{TK_PAREN_CLOSE, PIPE_SEMI_SEQUENCE, SUBSHELL, TK_PAREN_OPEN},
|
||||||
|
|
@ -220,7 +221,9 @@ t_aggrematch g_aggrematch[] =
|
||||||
{COMPOUND_LIST, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS},
|
{COMPOUND_LIST, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS},
|
||||||
{CLOSE_LIST, PATTERN, CASE_LIST_NS, PATTERN_CASE},
|
{CLOSE_LIST, PATTERN, CASE_LIST_NS, PATTERN_CASE},
|
||||||
{CLOSE_LIST, FUNC_NAME, FUNCTION_DEFINITION, FUNC_NAME},
|
{CLOSE_LIST, FUNC_NAME, FUNCTION_DEFINITION, FUNC_NAME},
|
||||||
|
{SUBSHELL, TK_PAREN_OPEN, SEMI_SUBSHELL, 0},
|
||||||
{SUBSHELL, ALL, COMPOUND_COMMAND, 0},
|
{SUBSHELL, ALL, COMPOUND_COMMAND, 0},
|
||||||
|
{BRACE_CLAUSE, TK_LBRACE, SEMI_BRACE, 0},
|
||||||
{BRACE_CLAUSE, ALL, COMPOUND_COMMAND, 0},
|
{BRACE_CLAUSE, ALL, COMPOUND_COMMAND, 0},
|
||||||
{COMPOUND_COMMAND, FUNC_NAME, COMMAND, FUNC_NAME},
|
{COMPOUND_COMMAND, FUNC_NAME, COMMAND, FUNC_NAME},
|
||||||
{AND_OR_MINOR, PIPE_SEMI_SEQUENCE, AND_OR_MAJOR, PIPE_SEMI_SEQUENCE},
|
{AND_OR_MINOR, PIPE_SEMI_SEQUENCE, AND_OR_MAJOR, PIPE_SEMI_SEQUENCE},
|
||||||
|
|
@ -379,15 +382,20 @@ int aggregate_sym(t_list **stack, t_sym *new_sym, t_parstate *state)
|
||||||
return (1);
|
return (1);
|
||||||
i = -1;
|
i = -1;
|
||||||
head = (*stack)->content;
|
head = (*stack)->content;
|
||||||
|
DG("aggregate head %s && sym %s",
|
||||||
|
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));
|
||||||
*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));
|
||||||
}
|
}
|
||||||
if (eval_sym(stack, *new_sym) && !(*state = ERROR))
|
if (eval_sym(stack, *new_sym) && !(*state = ERROR))
|
||||||
return (1);
|
return (1);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/11 16:11:21 by ariard #+# #+# */
|
/* Created: 2017/03/11 16:11:21 by ariard #+# #+# */
|
||||||
/* Updated: 2017/03/22 16:11:11 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:56:05 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -578,6 +578,7 @@ t_stackmatch g_stackmatch[] =
|
||||||
{TK_PAREN_CLOSE, COMPOUND_LIST},
|
{TK_PAREN_CLOSE, COMPOUND_LIST},
|
||||||
{TK_PAREN_CLOSE, FUNC_NAME},
|
{TK_PAREN_CLOSE, FUNC_NAME},
|
||||||
{TK_PAREN_CLOSE, OPEN_FUNC},
|
{TK_PAREN_CLOSE, OPEN_FUNC},
|
||||||
|
{TK_PAREN_CLOSE, SEMI_SUBSHELL},
|
||||||
{TK_RBRACE, TK_SEMI},
|
{TK_RBRACE, TK_SEMI},
|
||||||
{TK_RBRACE, END_COMMAND},
|
{TK_RBRACE, END_COMMAND},
|
||||||
{TK_RBRACE, SEPARATOR_OP},
|
{TK_RBRACE, SEPARATOR_OP},
|
||||||
|
|
@ -1047,6 +1048,7 @@ t_stackmatch g_stackmatch[] =
|
||||||
{SUBSHELL, COMPLETE_CONDITION},
|
{SUBSHELL, COMPLETE_CONDITION},
|
||||||
{SUBSHELL, CONDITION},
|
{SUBSHELL, CONDITION},
|
||||||
{SUBSHELL, AND_OR_MAJOR},
|
{SUBSHELL, AND_OR_MAJOR},
|
||||||
|
{SEMI_SUBSHELL, TK_PAREN_OPEN},
|
||||||
{COMPOUND_COMMAND, LINEBREAK},
|
{COMPOUND_COMMAND, LINEBREAK},
|
||||||
{COMPOUND_COMMAND, TK_PAREN_OPEN},
|
{COMPOUND_COMMAND, TK_PAREN_OPEN},
|
||||||
{COMPOUND_COMMAND, TK_LBRACE},
|
{COMPOUND_COMMAND, TK_LBRACE},
|
||||||
|
|
@ -1271,6 +1273,7 @@ int eval_sym(t_list **stack, t_sym new_sym)
|
||||||
return (1);
|
return (1);
|
||||||
head = (*stack)->content;
|
head = (*stack)->content;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
DG("eval head %s && sym %s", read_state(*head), read_state(new_sym));
|
||||||
while (g_stackmatch[i].top)
|
while (g_stackmatch[i].top)
|
||||||
{
|
{
|
||||||
if (new_sym == g_stackmatch[i].top && *head == g_stackmatch[i].under)
|
if (new_sym == g_stackmatch[i].top && *head == g_stackmatch[i].under)
|
||||||
|
|
|
||||||
|
|
@ -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/22 16:10:09 by ariard ### ########.fr */
|
/* Updated: 2017/03/22 16:34:24 by ariard ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue