parsing tk_bang && brace_clause}
This commit is contained in:
parent
ca55620d71
commit
5e5a4a122a
11 changed files with 23 additions and 43 deletions
30
42sh/error
30
42sh/error
|
|
@ -1,30 +0,0 @@
|
|||
42sh
|
||||
Makefile
|
||||
STDBUG
|
||||
TESTSHELL
|
||||
donovan_segaults_06-02
|
||||
error
|
||||
includes
|
||||
libft
|
||||
objs
|
||||
pdf
|
||||
sample
|
||||
src
|
||||
test_framework.sh
|
||||
testmake
|
||||
update_makefile.sh
|
||||
42sh
|
||||
Makefile
|
||||
STDBUG
|
||||
TESTSHELL
|
||||
donovan_segaults_06-02
|
||||
error
|
||||
includes
|
||||
libft
|
||||
objs
|
||||
pdf
|
||||
sample
|
||||
src
|
||||
test_framework.sh
|
||||
testmake
|
||||
update_makefile.sh
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/30 16:29:57 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/08 17:11:35 by jhalford ### ########.fr */
|
||||
/* Updated: 2017/03/09 18:48:00 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -31,6 +31,8 @@ int lexer_sep(t_list **alst, t_lexer *lexer)
|
|||
token->type = cn == '|' ? TK_OR_IF : TK_PIPE;
|
||||
else if (c == ';')
|
||||
token->type = cn == ';' ? TK_DSEMI : TK_SEMI;
|
||||
else if (c == '!')
|
||||
token->type = TK_BANG;
|
||||
if (token->type == TK_AND_IF || token->type == TK_OR_IF
|
||||
|| token->type == TK_DSEMI)
|
||||
lexer->pos++;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/07 23:35:32 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/09 18:54:07 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,8 +17,12 @@ char *ft_putast(void *nodein)
|
|||
t_astnode *node;
|
||||
node = nodein;
|
||||
|
||||
if (node->type == TK_BANG)
|
||||
return ("TK_BANG");
|
||||
if (node->type == MATH)
|
||||
return ("MATH");
|
||||
if (node->type == MATH_PLUS)
|
||||
return ("MATH_PLUS");
|
||||
if (node->type == TK_DSEMI)
|
||||
return ("TK_DSEMI");
|
||||
if (node->type == WORDLIST)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/09 17:37:38 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/09 19:46:24 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/15 20:49:15 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/09 16:04:46 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/09 19:44:51 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/24 18:41:50 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/07 22:46:36 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/09 19:46:44 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -23,6 +23,8 @@ int issubshell(t_btree **ast, t_list **lst)
|
|||
node = (*ast)->item;
|
||||
if (node->type == SUBSHELL && node->full == 0)
|
||||
return (1);
|
||||
if (node->type == TK_LBRACE && node->full == 0)
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ t_aggrematch g_aggrematch[] =
|
|||
{NEWLINE_LIST, TK_ELIF, TK_ELIF, TK_ELIF},
|
||||
{NEWLINE_LIST, TK_ELSE, TK_ELSE, TK_ELSE},
|
||||
{NEWLINE_LIST, TK_WHILE, TK_WHILE, TK_WHILE},
|
||||
{NEWLINE_LIST, TK_LBRACE, TK_LBRACE, TK_LBRACE},
|
||||
{NEWLINE_LIST, TK_UNTIL, TK_UNTIL, TK_UNTIL},
|
||||
{NEWLINE_LIST, CASE_LIST_NS, CASE_LIST_NS, CASE_LIST_NS},
|
||||
{NEWLINE_LIST, NEWLINE_LIST, NEWLINE_LIST, NEWLINE},
|
||||
|
|
@ -367,21 +368,21 @@ int aggregate_sym(t_list **stack, t_sym *new_sym, t_parstate *state)
|
|||
return (1);
|
||||
i = 0;
|
||||
head = (*stack)->content;
|
||||
// DG("aggregate head %s && sym %s",
|
||||
// read_state(*head), read_state(*new_sym));
|
||||
DG("aggregate head %s && sym %s",
|
||||
read_state(*head), read_state(*new_sym));
|
||||
while (g_aggrematch[i].top)
|
||||
{
|
||||
if (*new_sym == g_aggrematch[i].top
|
||||
&& 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;
|
||||
if (g_aggrematch[i].erase_sym)
|
||||
{
|
||||
pop_stack(stack, g_aggrematch[i].erase_sym);
|
||||
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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/15 18:32:59 by ariard #+# #+# */
|
||||
/* Updated: 2017/03/09 18:33:05 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/09 19:45:53 by ariard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -429,6 +429,7 @@ t_stackmatch g_stackmatch[] =
|
|||
// watch !
|
||||
{TK_PAREN_OPEN, AND_OR_MAJOR},
|
||||
{TK_PAREN_OPEN, TK_WHILE},
|
||||
{TK_PAREN_OPEN, TK_LBRACE},
|
||||
{TK_PAREN_OPEN, FUNC_NAME},
|
||||
{TK_PAREN_OPEN, TK_UNTIL},
|
||||
{TK_PAREN_OPEN, TK_DO},
|
||||
|
|
@ -817,6 +818,7 @@ t_stackmatch g_stackmatch[] =
|
|||
{WHILE_CLAUSE, TK_DO},
|
||||
{WHILE_CLAUSE, TK_PAREN_CLOSE},
|
||||
{WHILE_CLAUSE, TK_WHILE},
|
||||
{WHILE_CLAUSE, TK_LBRACE},
|
||||
{WHILE_CLAUSE, FUNC_NAME},
|
||||
{WHILE_CLAUSE, TK_UNTIL},
|
||||
{WHILE_CLAUSE, TK_IF},
|
||||
|
|
@ -954,6 +956,7 @@ t_stackmatch g_stackmatch[] =
|
|||
{SUBSHELL, SEPARATOR_OP},
|
||||
{SUBSHELL, NEWLINE_LIST},
|
||||
{SUBSHELL, SEQUENCE},
|
||||
{SUBSHELL, TK_LBRACE},
|
||||
// watch !
|
||||
{SUBSHELL, SEPARATOR_OP},
|
||||
{SUBSHELL, NEWLINE_LIST},
|
||||
|
|
@ -1059,8 +1062,6 @@ t_stackmatch g_stackmatch[] =
|
|||
{TK_BANG, TK_PAREN_OPEN},
|
||||
{TK_BANG, TK_LBRACE},
|
||||
{TK_BANG, COMPLETE_COMMANDS},
|
||||
{TK_BANG, TK_BANG},
|
||||
{TK_BANG, TK_BANG},
|
||||
{TK_BANG, SEPARATOR_OP},
|
||||
{TK_BANG, NEWLINE_LIST},
|
||||
{TK_BANG, AND_OR_MAJOR},
|
||||
|
|
@ -1191,7 +1192,7 @@ int eval_sym(t_list **stack, t_sym new_sym)
|
|||
if (!*stack)
|
||||
return (1);
|
||||
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;
|
||||
while (g_stackmatch[i].top)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue