heredoc changes first step

This commit is contained in:
Jack Halford 2017-03-08 13:48:58 +01:00
parent e711ffc927
commit 8528951041
6 changed files with 20 additions and 23 deletions

View file

@ -10,20 +10,20 @@ int lexer_dless(t_list **alst, t_lexer *lexer)
(void)lexer; (void)lexer;
heredoc_lst = *(t_list**)lexer->heredoc_stack->content; heredoc_lst = *(t_list**)lexer->heredoc_stack->content;
heredoc_tok = heredoc_lst->content; heredoc_tok = heredoc_lst->content;
if (!(heredoc_lst->next)) /* if (!(heredoc_lst->next)) */
{ /* { */
ft_dprintf(2, "{red}%s: parse error near `\\n'{eoc}\n", SHELL_NAME); /* ft_dprintf(2, "{red}%s: parse error near `\\n'{eoc}\n", SHELL_NAME); */
return (1); /* return (1); */
} /* } */
eof_tok = heredoc_lst->next->content; /* eof_tok = heredoc_lst->next->content; */
if (!(eof_tok->type == TK_WORD)) /* if (!(eof_tok->type == TK_WORD)) */
{ /* { */
ft_dprintf(2, "{red}%s: expected word token after <<{eoc}\n", SHELL_NAME); /* ft_dprintf(2, "{red}%s: expected word token after <<{eoc}\n", SHELL_NAME); */
return (1); /* return (1); */
} /* } */
DG("heredoc contains [%s]", heredoc_tok->data); /* DG("heredoc contains [%s]", heredoc_tok->data); */
DG("heredoc ends at [%s]", eof_tok->data); /* DG("heredoc ends at [%s]", eof_tok->data); */
DG("input is [%s]", lexer->str + lexer->pos); /* DG("input is [%s]", lexer->str + lexer->pos); */
if (ft_strcmp(eof_tok->data, lexer->str + lexer->pos) == 0) if (ft_strcmp(eof_tok->data, lexer->str + lexer->pos) == 0)
{ {
pop(&lexer->stack); pop(&lexer->stack);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 12:06:53 by jhalford #+# #+# */ /* Created: 2016/12/03 12:06:53 by jhalford #+# #+# */
/* Updated: 2017/03/08 12:10:38 by jhalford ### ########.fr */ /* Updated: 2017/03/08 13:27:33 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,7 +17,6 @@ int lexer_less(t_list **alst, t_lexer *lexer)
t_token *token; t_token *token;
token = (*alst)->content; token = (*alst)->content;
token_append(token, lexer, 0, 0);
lexer->pos++; lexer->pos++;
if (lexer->str[lexer->pos] == '&') if (lexer->str[lexer->pos] == '&')
{ {
@ -28,11 +27,9 @@ int lexer_less(t_list **alst, t_lexer *lexer)
} }
if (lexer->str[lexer->pos] == '<') if (lexer->str[lexer->pos] == '<')
{ {
token_free(token, 0);
(*alst)->content = token_init();
token->type = TK_DLESS; token->type = TK_DLESS;
lexer->pos++;
push(&lexer->stack, DLESS); push(&lexer->stack, DLESS);
lexer->pos++;
lexer->state = DEFAULT; lexer->state = DEFAULT;
ft_lsteadd(&lexer->heredoc_stack, ft_lstnew(alst, sizeof(alst))); ft_lsteadd(&lexer->heredoc_stack, ft_lstnew(alst, sizeof(alst)));
return (lexer_lex(&(*alst)->next, lexer)); return (lexer_lex(&(*alst)->next, lexer));

View file

@ -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/03/03 18:57:46 by ariard ### ########.fr */ /* Updated: 2017/03/08 13:22:19 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 15:30:25 by jhalford #+# #+# */ /* Created: 2016/11/10 15:30:25 by jhalford #+# #+# */
/* Updated: 2017/02/20 20:55:35 by ariard ### ########.fr */ /* Updated: 2017/03/08 13:21:55 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
/* Updated: 2017/03/08 13:05:23 by jhalford ### ########.fr */ /* Updated: 2017/03/08 13:48:27 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/03/08 12:59:55 by jhalford ### ########.fr */ /* Updated: 2017/03/08 13:27:47 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */