From 2ad34631e30e663ba6634ae607f10ccef63abfd6 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Fri, 3 Mar 2017 17:58:08 +0100 Subject: [PATCH] parentheses dont trigger more input after lexing --- 42sh/Makefile | 6 +----- 42sh/includes/lexer.h | 4 ++-- 42sh/src/exec/exec_command.c | 2 +- 42sh/src/lexer/get_lexer_stack.c | 12 ++++++++++++ 42sh/src/lexer/get_state_global.c | 2 +- 42sh/src/lexer/lexer_bquote.c | 2 +- 42sh/src/lexer/lexer_default.c | 2 +- 42sh/src/lexer/lexer_lex.c | 4 ++-- 42sh/src/lexer/lexer_number.c | 2 +- 42sh/src/lexer/lexer_paren.c | 12 ++++++++++++ 42sh/src/lexer/lexer_word.c | 26 +------------------------- 42sh/src/main/data_init.c | 2 +- 42sh/src/main/main.c | 8 +++++--- 13 files changed, 41 insertions(+), 43 deletions(-) diff --git a/42sh/Makefile b/42sh/Makefile index ae67e26f..3b26beb7 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -6,11 +6,7 @@ # By: wescande +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2016/08/29 21:32:58 by wescande #+# #+# # -<<<<<<< HEAD -# Updated: 2017/03/03 14:36:32 by ariard ### ########.fr # -======= -# Updated: 2017/03/02 16:23:48 by jhalford ### ########.fr # ->>>>>>> pda_execution +# Updated: 2017/03/03 17:56:12 by jhalford ### ########.fr # # # # **************************************************************************** # diff --git a/42sh/includes/lexer.h b/42sh/includes/lexer.h index 927d5dec..078b2005 100644 --- a/42sh/includes/lexer.h +++ b/42sh/includes/lexer.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */ -/* Updated: 2017/03/02 17:15:15 by jhalford ### ########.fr */ +/* Updated: 2017/03/03 17:55:18 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,6 +23,7 @@ | TK_DO | TK_IF | TK_FI | TK_THEN | TK_ELIF | TK_ELSE) enum e_lexstate { + PAREN, DEFAULT, NEWLINE, DELIM, @@ -39,7 +40,6 @@ enum e_lexstate BQUOTE, DQUOTE_BQUOTE, BACKSLASH, - PAREN, CURLY_BRACKETS, ASSIGNEMENT_WORD, COMMENT, diff --git a/42sh/src/exec/exec_command.c b/42sh/src/exec/exec_command.c index d39de6f2..cf915722 100644 --- a/42sh/src/exec/exec_command.c +++ b/42sh/src/exec/exec_command.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 17:28:14 by jhalford #+# #+# */ -/* Updated: 2017/03/03 17:31:12 by jhalford ### ########.fr */ +/* Updated: 2017/03/03 17:37:07 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/get_lexer_stack.c b/42sh/src/lexer/get_lexer_stack.c index 10ce9b70..d8c449ec 100644 --- a/42sh/src/lexer/get_lexer_stack.c +++ b/42sh/src/lexer/get_lexer_stack.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* get_lexer_stack.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/03 17:39:45 by jhalford #+# #+# */ +/* Updated: 2017/03/03 17:40:24 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "lexer.h" int get_lexer_stack(t_lexer lexer) diff --git a/42sh/src/lexer/get_state_global.c b/42sh/src/lexer/get_state_global.c index e677ed39..550e7b2c 100644 --- a/42sh/src/lexer/get_state_global.c +++ b/42sh/src/lexer/get_state_global.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 20:39:06 by jhalford #+# #+# */ -/* Updated: 2017/03/03 17:31:47 by jhalford ### ########.fr */ +/* Updated: 2017/03/03 17:56:09 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_bquote.c b/42sh/src/lexer/lexer_bquote.c index bf8a9b7f..b4360556 100644 --- a/42sh/src/lexer/lexer_bquote.c +++ b/42sh/src/lexer/lexer_bquote.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 22:03:48 by jhalford #+# #+# */ -/* Updated: 2017/03/03 16:48:07 by jhalford ### ########.fr */ +/* Updated: 2017/03/03 17:45:53 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_default.c b/42sh/src/lexer/lexer_default.c index d2acede7..94bf796c 100644 --- a/42sh/src/lexer/lexer_default.c +++ b/42sh/src/lexer/lexer_default.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 18:36:21 by jhalford #+# #+# */ -/* Updated: 2017/03/01 23:40:16 by ariard ### ########.fr */ +/* Updated: 2017/03/03 17:55:57 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_lex.c b/42sh/src/lexer/lexer_lex.c index 27535a56..75f0e4f1 100644 --- a/42sh/src/lexer/lexer_lex.c +++ b/42sh/src/lexer/lexer_lex.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 17:08:51 by jhalford #+# #+# */ -/* Updated: 2017/02/24 21:38:42 by ariard ### ########.fr */ +/* Updated: 2017/03/03 17:55:55 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,7 @@ int (*g_lexer[])(t_list **alst, t_lexer *lexer) = { + &lexer_paren, &lexer_default, &lexer_newline, &lexer_delim, @@ -30,7 +31,6 @@ int (*g_lexer[])(t_list **alst, t_lexer *lexer) = &lexer_bquote, &lexer_bquote, &lexer_backslash, - &lexer_paren, &lexer_curly_brackets, &lexer_assignement_word, &lexer_comment, diff --git a/42sh/src/lexer/lexer_number.c b/42sh/src/lexer/lexer_number.c index 8759c156..90562cb1 100644 --- a/42sh/src/lexer/lexer_number.c +++ b/42sh/src/lexer/lexer_number.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 12:06:45 by jhalford #+# #+# */ -/* Updated: 2017/03/01 23:39:37 by ariard ### ########.fr */ +/* Updated: 2017/03/03 17:35:30 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_paren.c b/42sh/src/lexer/lexer_paren.c index dd795357..e80b6a1a 100644 --- a/42sh/src/lexer/lexer_paren.c +++ b/42sh/src/lexer/lexer_paren.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* lexer_paren.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/03 17:37:15 by jhalford #+# #+# */ +/* Updated: 2017/03/03 17:48:28 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "lexer.h" int lexer_paren(t_list **alst, t_lexer *lexer) diff --git a/42sh/src/lexer/lexer_word.c b/42sh/src/lexer/lexer_word.c index 50ad864f..066379f2 100644 --- a/42sh/src/lexer/lexer_word.c +++ b/42sh/src/lexer/lexer_word.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 12:07:11 by jhalford #+# #+# */ -/* Updated: 2017/03/03 17:31:56 by jhalford ### ########.fr */ +/* Updated: 2017/03/03 17:56:07 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -51,27 +51,3 @@ int lexer_word(t_list **alst, t_lexer *lexer) lexer->pos++; return (lexer_lex(alst, lexer)); } - -/* -int lexer_word(t_list **alst, t_lexer *lexer) -{ - t_token *token; - t_lexstate state; - - token = (*alst)->content; - token->type = TK_WORD; - if ((state = get_state_global(lexer))) - { - lexer->state = state; - return (lexer_lex(alst, lexer)); - } - if ((state = get_state_redir(lexer))) - { - lexer->state = state; - return (lexer_lex(alst, lexer)); - } - token_append(token, lexer, 0, 0); - lexer->pos++; - return (lexer_lex(alst, lexer)); -} -*/ diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index 0a157747..1aa6c777 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2017/03/03 16:48:29 by jhalford ### ########.fr */ +/* Updated: 2017/03/03 17:39:30 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 75ce40bd..820abfb9 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/03 17:32:29 by jhalford ### ########.fr */ +/* Updated: 2017/03/03 17:55:01 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,7 +31,6 @@ int handle_instruction(int fd) if ((ret = readline(fd, get_lexer_stack(lexer) || parser.state == UNDEFINED, &str))) { - /* ft_putstr("bonjour"); */ if (ret == -1) return (-1); return (parser.state == UNDEFINED ? error_EOF() : 1); @@ -42,9 +41,11 @@ int handle_instruction(int fd) else if (get_lexer_stack(lexer) == DLESS) lexer.state = DLESS; ltoken = ft_lstlast(token); + DG(); if (lexer_lex(token ? <oken : &token, &lexer)) return (1); - if (get_lexer_stack(lexer)) + DG(); + if (get_lexer_stack(lexer) > 1) continue ; lexer.state = DEFAULT; token_print(token); @@ -62,6 +63,7 @@ int handle_instruction(int fd) error_syntax(&token); token = NULL; } + DG(); DG("Before execution:"); btree_print(STDBUG, ast, &ft_putast); if (ft_exec(&ast))