parentheses dont trigger more input after lexing
This commit is contained in:
parent
2926a9d00d
commit
2ad34631e3
13 changed files with 41 additions and 43 deletions
|
|
@ -6,11 +6,7 @@
|
||||||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
||||||
<<<<<<< HEAD
|
# Updated: 2017/03/03 17:56:12 by jhalford ### ########.fr #
|
||||||
# Updated: 2017/03/03 14:36:32 by ariard ### ########.fr #
|
|
||||||
=======
|
|
||||||
# Updated: 2017/03/02 16:23:48 by jhalford ### ########.fr #
|
|
||||||
>>>>>>> pda_execution
|
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/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)
|
| TK_DO | TK_IF | TK_FI | TK_THEN | TK_ELIF | TK_ELSE)
|
||||||
enum e_lexstate
|
enum e_lexstate
|
||||||
{
|
{
|
||||||
|
PAREN,
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
NEWLINE,
|
NEWLINE,
|
||||||
DELIM,
|
DELIM,
|
||||||
|
|
@ -39,7 +40,6 @@ enum e_lexstate
|
||||||
BQUOTE,
|
BQUOTE,
|
||||||
DQUOTE_BQUOTE,
|
DQUOTE_BQUOTE,
|
||||||
BACKSLASH,
|
BACKSLASH,
|
||||||
PAREN,
|
|
||||||
CURLY_BRACKETS,
|
CURLY_BRACKETS,
|
||||||
ASSIGNEMENT_WORD,
|
ASSIGNEMENT_WORD,
|
||||||
COMMENT,
|
COMMENT,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/14 17:28:14 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* get_lexer_stack.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/03 17:39:45 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2017/03/03 17:40:24 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
|
|
||||||
int get_lexer_stack(t_lexer lexer)
|
int get_lexer_stack(t_lexer lexer)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/09 20:39:06 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/09 22:03:48 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 18:36:21 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/09 17:08:51 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) =
|
int (*g_lexer[])(t_list **alst, t_lexer *lexer) =
|
||||||
{
|
{
|
||||||
|
&lexer_paren,
|
||||||
&lexer_default,
|
&lexer_default,
|
||||||
&lexer_newline,
|
&lexer_newline,
|
||||||
&lexer_delim,
|
&lexer_delim,
|
||||||
|
|
@ -30,7 +31,6 @@ int (*g_lexer[])(t_list **alst, t_lexer *lexer) =
|
||||||
&lexer_bquote,
|
&lexer_bquote,
|
||||||
&lexer_bquote,
|
&lexer_bquote,
|
||||||
&lexer_backslash,
|
&lexer_backslash,
|
||||||
&lexer_paren,
|
|
||||||
&lexer_curly_brackets,
|
&lexer_curly_brackets,
|
||||||
&lexer_assignement_word,
|
&lexer_assignement_word,
|
||||||
&lexer_comment,
|
&lexer_comment,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:06:45 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 */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,15 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* lexer_paren.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/03 17:37:15 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2017/03/03 17:48:28 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
|
|
||||||
int lexer_paren(t_list **alst, t_lexer *lexer)
|
int lexer_paren(t_list **alst, t_lexer *lexer)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/03 12:07:11 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++;
|
lexer->pos++;
|
||||||
return (lexer_lex(alst, lexer));
|
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));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
||||||
|
|
@ -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/03 16:48:29 by jhalford ### ########.fr */
|
/* Updated: 2017/03/03 17:39:30 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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/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) ||
|
if ((ret = readline(fd, get_lexer_stack(lexer) ||
|
||||||
parser.state == UNDEFINED, &str)))
|
parser.state == UNDEFINED, &str)))
|
||||||
{
|
{
|
||||||
/* ft_putstr("bonjour"); */
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
return (parser.state == UNDEFINED ? error_EOF() : 1);
|
return (parser.state == UNDEFINED ? error_EOF() : 1);
|
||||||
|
|
@ -42,9 +41,11 @@ int handle_instruction(int fd)
|
||||||
else if (get_lexer_stack(lexer) == DLESS)
|
else if (get_lexer_stack(lexer) == DLESS)
|
||||||
lexer.state = DLESS;
|
lexer.state = DLESS;
|
||||||
ltoken = ft_lstlast(token);
|
ltoken = ft_lstlast(token);
|
||||||
|
DG();
|
||||||
if (lexer_lex(token ? <oken : &token, &lexer))
|
if (lexer_lex(token ? <oken : &token, &lexer))
|
||||||
return (1);
|
return (1);
|
||||||
if (get_lexer_stack(lexer))
|
DG();
|
||||||
|
if (get_lexer_stack(lexer) > 1)
|
||||||
continue ;
|
continue ;
|
||||||
lexer.state = DEFAULT;
|
lexer.state = DEFAULT;
|
||||||
token_print(token);
|
token_print(token);
|
||||||
|
|
@ -62,6 +63,7 @@ int handle_instruction(int fd)
|
||||||
error_syntax(&token);
|
error_syntax(&token);
|
||||||
token = NULL;
|
token = NULL;
|
||||||
}
|
}
|
||||||
|
DG();
|
||||||
DG("Before execution:");
|
DG("Before execution:");
|
||||||
btree_print(STDBUG, ast, &ft_putast);
|
btree_print(STDBUG, ast, &ft_putast);
|
||||||
if (ft_exec(&ast))
|
if (ft_exec(&ast))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue