andor seems good

This commit is contained in:
Antoine Riard 2017-03-29 13:43:07 +02:00
parent 8b6fd7bb1d
commit e87dbff14c
11 changed files with 20 additions and 21 deletions

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/22 17:22:51 by ariard #+# #+# */ /* Created: 2017/03/22 17:22:51 by ariard #+# #+# */
/* Updated: 2017/03/23 00:32:27 by ariard ### ########.fr */ /* Updated: 2017/03/29 13:29:26 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -1,8 +1 @@
pwd > file && pwd >> file || ls | cat && ls | cat >> file || ls pwd > file && pwd >> file || ls | cat && ls | cat >> file || ls
cat -e file
sleep 2
echo "My sample :"
echo
cat sample/andor.sh

View file

@ -6,7 +6,7 @@
/* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */ /* By: wescande <wescande@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/07 20:33:45 by wescande #+# #+# */ /* Created: 2017/03/07 20:33:45 by wescande #+# #+# */
/* Updated: 2017/03/27 15:05:49 by ariard ### ########.fr */ /* Updated: 2017/03/29 12:22:56 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,7 +19,8 @@ int exec_case_branch(t_btree **ast)
t_exec *exec; t_exec *exec;
exec = &data_singleton()->exec; exec = &data_singleton()->exec;
if (EXEC_IS_CASE_BRANCH(exec->attrs)) if (EXEC_IS_CASE_BRANCH(exec->attrs) || !exec->case_pattern
|| !*exec->case_pattern)
return (0); return (0);
node = (*ast)->item; node = (*ast)->item;
av = token_to_argv(node->data.cmd.token, 1); av = token_to_argv(node->data.cmd.token, 1);

View file

@ -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/28 23:26:06 by ariard ### ########.fr */ /* Updated: 2017/03/29 13:42:01 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -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/27 17:23:36 by ariard ### ########.fr */ /* Updated: 2017/03/29 13:42:08 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -74,7 +74,7 @@ static t_aggrematch g_aggrematch[] =
{LINEBREAK, CMD_SUPERIOR, SEPARATOR_OP, 0}, {LINEBREAK, CMD_SUPERIOR, SEPARATOR_OP, 0},
{LINEBREAK, PIPE_SEMI_SEQUENCE, PIPE_SEQUENCE, PIPE_SEMI_SEQUENCE}, {LINEBREAK, PIPE_SEMI_SEQUENCE, PIPE_SEQUENCE, PIPE_SEMI_SEQUENCE},
{LINEBREAK, PIPE_CLOSE_SEQUENCE, PIPE_SEQUENCE, PIPE_CLOSE_SEQUENCE}, {LINEBREAK, PIPE_CLOSE_SEQUENCE, PIPE_SEQUENCE, PIPE_CLOSE_SEQUENCE},
{LINEBREAK, COMPOUND_LIST, COMPOUND_LIST, COMPOUND_LIST}, {LINEBREAK, COMPOUND_LIST, PROGRAM, LINEBREAK},
{LINEBREAK, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS}, {LINEBREAK, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS},
{NEWLINE_LIST, CMD_NAME, CMD_SUPERIOR, CMD_NAME}, {NEWLINE_LIST, CMD_NAME, CMD_SUPERIOR, CMD_NAME},
{NEWLINE_LIST, SEQUENTIAL_SEP, SEQUENTIAL_SEP, SEQUENTIAL_SEP}, {NEWLINE_LIST, SEQUENTIAL_SEP, SEQUENTIAL_SEP, SEQUENTIAL_SEP},
@ -231,6 +231,8 @@ static t_aggrematch g_aggrematch[] =
{AND_OR_MINOR, LINEBREAK, AND_OR_MAJOR, 0}, {AND_OR_MINOR, LINEBREAK, AND_OR_MAJOR, 0},
{AND_OR_MINOR, TK_PAREN_OPEN, AND_OR_MAJOR, 0}, {AND_OR_MINOR, TK_PAREN_OPEN, AND_OR_MAJOR, 0},
{AND_OR_MINOR, TK_LBRACE, AND_OR_MAJOR, 0}, {AND_OR_MINOR, TK_LBRACE, AND_OR_MAJOR, 0},
{AND_OR_MINOR, CMD_SUPERIOR, AND_OR_MAJOR, 0},
{AND_OR_MINOR, COMPOUND_LIST, AND_OR_MAJOR, 0},
{AND_OR_MINOR, COMPLETE_COMMANDS, AND_OR_MAJOR, 0}, {AND_OR_MINOR, COMPLETE_COMMANDS, AND_OR_MAJOR, 0},
{AND_OR_MINOR, AND_OR_MAJOR, AND_OR_MAJOR, 0}, {AND_OR_MINOR, AND_OR_MAJOR, AND_OR_MAJOR, 0},
{AND_OR_MINOR, TK_BANG, AND_OR_MAJOR, TK_BANG}, {AND_OR_MINOR, TK_BANG, AND_OR_MAJOR, TK_BANG},
@ -280,7 +282,7 @@ static t_aggrematch g_aggrematch[] =
{COMPOUND_COMMAND, CONDITION, PIPE_CLOSE_SEQUENCE, 0}, {COMPOUND_COMMAND, CONDITION, PIPE_CLOSE_SEQUENCE, 0},
{END_COMMAND, SEQUENCE, PIPE_SEQUENCE, SEQUENCE}, {END_COMMAND, SEQUENCE, PIPE_SEQUENCE, SEQUENCE},
{END_COMMAND, PIPE_SEMI_SEQUENCE, PIPE_SEQUENCE, PIPE_SEMI_SEQUENCE}, {END_COMMAND, PIPE_SEMI_SEQUENCE, PIPE_SEQUENCE, PIPE_SEMI_SEQUENCE},
{END_COMMAND, AND_OR_MAJOR, LIST, AND_OR_MAJOR}, {END_COMMAND, AND_OR_MAJOR, COMPOUND_LIST, AND_OR_MAJOR},
{END_COMMAND, TK_WHILE, PIPE_SEQUENCE, 0}, {END_COMMAND, TK_WHILE, PIPE_SEQUENCE, 0},
{END_COMMAND, TK_WHILE, PIPE_SEQUENCE, 0}, {END_COMMAND, TK_WHILE, PIPE_SEQUENCE, 0},
{END_COMMAND, TK_UNTIL, PIPE_SEQUENCE, 0}, {END_COMMAND, TK_UNTIL, PIPE_SEQUENCE, 0},

View file

@ -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/24 17:02:43 by ariard ### ########.fr */ /* Updated: 2017/03/29 13:28:38 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -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/27 21:03:04 by ariard ### ########.fr */ /* Updated: 2017/03/29 13:42:14 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -1114,6 +1114,8 @@ static t_stackmatch g_stackmatch[] =
{AND_OR_MINOR, TK_BANG}, {AND_OR_MINOR, TK_BANG},
{AND_OR_MINOR, TK_PAREN_OPEN}, {AND_OR_MINOR, TK_PAREN_OPEN},
{AND_OR_MINOR, TK_LBRACE}, {AND_OR_MINOR, TK_LBRACE},
{AND_OR_MINOR, CMD_SUPERIOR},
{AND_OR_MINOR, COMPOUND_LIST},
{AND_OR_MINOR, COMPLETE_COMMANDS}, {AND_OR_MINOR, COMPLETE_COMMANDS},
{AND_OR_MINOR, AND_OR_MAJOR}, {AND_OR_MINOR, AND_OR_MAJOR},
{PIPE_SEQUENCE, TK_WHILE}, {PIPE_SEQUENCE, TK_WHILE},

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 16:17:38 by ariard #+# #+# */ /* Created: 2017/03/11 16:17:38 by ariard #+# #+# */
/* Updated: 2017/03/25 15:48:25 by ariard ### ########.fr */ /* Updated: 2017/03/29 13:41:44 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -26,6 +26,7 @@ static int end_instruction(t_list **stack)
head = (*stack)->content; head = (*stack)->content;
if (*head == CMD_SUPERIOR || *head == PIPE_SEMI_SEQUENCE if (*head == CMD_SUPERIOR || *head == PIPE_SEMI_SEQUENCE
|| *head == COMPOUND_LIST
|| *head == COMPLETE_COMMANDS || *head == END_COMMAND) || *head == COMPLETE_COMMANDS || *head == END_COMMAND)
return (1); return (1);
return (0); return (0);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/16 19:30:17 by ariard #+# #+# */ /* Created: 2017/03/16 19:30:17 by ariard #+# #+# */
/* Updated: 2017/03/26 21:46:24 by jhalford ### ########.fr */ /* Updated: 2017/03/29 13:29:01 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/21 16:14:04 by ariard #+# #+# */ /* Created: 2017/02/21 16:14:04 by ariard #+# #+# */
/* Updated: 2017/03/26 21:36:48 by jhalford ### ########.fr */ /* Updated: 2017/03/29 13:27:45 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/16 20:31:32 by ariard #+# #+# */ /* Created: 2017/03/16 20:31:32 by ariard #+# #+# */
/* Updated: 2017/03/26 21:47:01 by jhalford ### ########.fr */ /* Updated: 2017/03/29 13:27:26 by ariard ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */