diff --git a/42sh/Makefile b/42sh/Makefile index c5061dff..f7785ee8 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -167,10 +167,6 @@ job-control/sigint_handler.c\ job-control/sigtstp_handler.c\ job-control/sigttin_handler.c\ job-control/sigttou_handler.c\ -lexer/.ft_post_tokenize.c.swp\ -lexer/.ft_tokenize.c.swp\ -lexer/.reduce_bquotes.c.swp\ -lexer/ft_post_tokenize.c\ lexer/get_lexer_stack.c\ lexer/get_reserved_words.c\ lexer/get_state_global.c\ @@ -178,7 +174,6 @@ lexer/get_state_redir.c\ lexer/lexer_backslash.c\ lexer/lexer_bquote.c\ lexer/lexer_comment.c\ -lexer/lexer_comment.c~HEAD\ lexer/lexer_default.c\ lexer/lexer_delim.c\ lexer/lexer_dless.c\ @@ -191,16 +186,11 @@ lexer/lexer_less.c\ lexer/lexer_lessand.c\ lexer/lexer_lex.c\ lexer/lexer_newline.c\ -lexer/lexer_newline.c~HEAD\ lexer/lexer_number.c\ lexer/lexer_paren.c\ lexer/lexer_quote.c\ lexer/lexer_sep.c\ -lexer/lexer_special.c\ -lexer/lexer_then.c\ lexer/lexer_word.c\ -lexer/reduce_bquotes.c\ -lexer/reduce_parens.c\ lexer/stack_to_prompt.c\ lexer/token_append.c\ lexer/token_cmp_type.c\ @@ -225,31 +215,16 @@ line-editing/move_up_and_down.c\ line-editing/print_and_del.c\ line-editing/queue.c\ line-editing/readline.c\ -main/.main.c.swp\ main/data_exit.c\ main/data_init.c\ main/data_singleton.c\ -main/ft_cleanup.c\ -main/ft_print_all_ast.c\ main/ft_putast.c\ main/ft_putast2.c\ -main/lib_expansion.c\ main/main.c\ -main/read_script.c\ -main/remove_trailing_esc_nl.c\ main/shell_exit.c\ main/shell_get_avdata.c\ main/shell_get_opts.c\ main/shell_init.c\ -main/shell_script.c\ -main/sig_handler.c\ -parser/.eval_sym.c.swo\ -parser/.eval_sym.c.swp\ -parser/.ft_parse.c.swo\ -parser/.produce_sym.c.swo\ -parser/.produce_sym.c.swp\ -parser/.read_stack.c.swo\ -parser/.read_stack.c.swp\ parser/add_cmd.c\ parser/add_condition.c\ parser/add_file.c\ @@ -262,7 +237,6 @@ parser/eval_sym.c\ parser/ft_parse.c\ parser/get_instruction.c\ parser/get_sub_instruction.c\ -parser/old_parse.c\ parser/parse.c\ parser/parse_dgreat.c\ parser/parse_dless.c\ diff --git a/42sh/includes/lexer.h b/42sh/includes/lexer.h index 348bf334..042aed97 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/02/20 20:20:07 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:26:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,13 +41,6 @@ enum e_lexstate BACKSLASH, VAR, SPECIAL, - WHILE, - DO, - DONE, - IF, - THEN, - FI, - COMMENT, PAREN, COMMENT, END, @@ -94,34 +87,7 @@ char *command_getoutput(char *command); int ft_is_delim(char c); int ft_is_delim_list(char c); -t_lexstate get_lexer_state(char *str); -int get_reserved_words(t_list **alst); -int lexer_default(t_list **alst, char *str); -int lexer_newline(t_list **alst, char *str); -int lexer_delim(t_list **alst, char *str); -int lexer_sep(t_list **alst, char *str); -int lexer_word(t_list **alst, char *str); -int lexer_number(t_list **alst, char *str); -int lexer_less(t_list **alst, char *str); -int lexer_great(t_list **alst, char *str); -int lexer_lessand(t_list **alst, char *str); -int lexer_greatand(t_list **alst, char *str); -int lexer_quote(t_list **alst, char *str); -int lexer_dquote(t_list **alst, char *str); -int lexer_backslash(t_list **alst, char *str); -int lexer_var(t_list **alst, char *str); -int lexer_special(t_list **alst, char *str); -int lexer_while(t_list **alst, char *str); -int lexer_do(t_list **alst, char *str); -int lexer_done(t_list **alst, char *str); -int lexer_if(t_list **alst, char *str); -int lexer_then(t_list **alst, char *str); -int lexer_fi(t_list **alst, char *str); -int lexer_list(t_list **alst, char *str); -int lexer_comment(t_list **alst, char *str); -======= char *stack_to_prompt(t_list *stack); - t_lexstate get_state_global(t_lexer *lexer); t_lexstate get_state_redir(t_lexer *lexer); int get_lexer_stack(t_lexer lexer); @@ -145,6 +111,5 @@ int lexer_backslash(t_list **alst, t_lexer *lexer); int lexer_paren(t_list **alst, t_lexer *lexer); int lexer_comment(t_list **alst, t_lexer *lexer); int lexer_end(t_list **alst, t_lexer *lexer); ->>>>>>> master #endif diff --git a/42sh/includes/minishell.h b/42sh/includes/minishell.h index c3368eed..ea79fd25 100644 --- a/42sh/includes/minishell.h +++ b/42sh/includes/minishell.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */ -/* Updated: 2017/02/20 20:23:20 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:39:18 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -65,7 +65,6 @@ struct s_data t_comp *comp; t_exec exec; t_jobc jobc; - t_script script; }; extern t_stof g_builtins[]; diff --git a/42sh/includes/parser.h b/42sh/includes/parser.h index 3cfa52c8..625551d7 100644 --- a/42sh/includes/parser.h +++ b/42sh/includes/parser.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/01 12:15:54 by jhalford #+# #+# */ -/* Updated: 2017/02/20 20:26:50 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:39:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,6 @@ * */ - enum e_sym { LINEBREAK = 1, @@ -50,11 +49,9 @@ enum e_sym TK_ELIF, TK_ELSE, TK_UNTIL, - TK_N_WORD, - TK_Q_WORD, - TK_DQ_WORD, + TK_WORD, TK_ASSIGNEMENT_WORD = 50, - TK_BANG, + TK_BANG, TK_NAME, TK_FOR, TK_IO_NUMBER, @@ -126,6 +123,8 @@ enum e_sym ALL = 200, }; +# define TK_REDIR(x) (TK_LESS <= x && x <= TK_GREATAND) + typedef int t_sym; # define MATCH_STACK(x, y) (x == y || y == ALL) @@ -175,7 +174,7 @@ typedef struct s_errormatch t_errormatch; extern t_errormatch g_errormatch[]; -int ft_parse2(t_btree **ast, t_list **token); +int ft_parse(t_btree **ast, t_list **token); int ft_parse(t_btree **ast, t_list **token); int produce_sym(t_sym stack, t_sym *new_sym, t_list **lst); @@ -187,7 +186,7 @@ int pop_stack(t_sym **stack, t_sym erase_sym); int error_syntax(t_list **token); -int ft_read_stack(t_sym *stack); +int ft_read_stack(t_sym *stack); char *read_state(t_sym current); #define UNDEFINED (1 << 0) @@ -228,7 +227,7 @@ int gen_node(t_btree **ast); /* * Build AST - * + * */ typedef struct s_parser t_parser; @@ -270,8 +269,6 @@ struct s_astnode t_astdata data; }; -extern t_parser g_parser[]; - int parse(t_btree **ast, t_list **token); int get_instruction(t_list **lst); diff --git a/42sh/src/exec/exec_command.c b/42sh/src/exec/exec_command.c index c6ddecb2..9b42f3f9 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/02/20 20:32:10 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:21:35 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/exec_elif.c b/42sh/src/exec/exec_elif.c index c248e434..235b1938 100644 --- a/42sh/src/exec/exec_elif.c +++ b/42sh/src/exec/exec_elif.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 18:08:53 by ariard #+# #+# */ -/* Updated: 2017/02/06 19:26:00 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:35:47 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,11 +17,10 @@ int exec_elif(t_btree **ast) int test; (void)ast; - test = 1; - if (test && data_singleton()->script.lc == 0) + test = 0; + if (test) { ft_exec(&(*ast)->right); - data_singleton()->script.lc = 1; } // btree_delone(ast, &ast_free); return (0); diff --git a/42sh/src/exec/exec_if.c b/42sh/src/exec/exec_if.c index 43c7aa87..667c32de 100644 --- a/42sh/src/exec/exec_if.c +++ b/42sh/src/exec/exec_if.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/06 18:07:31 by ariard #+# #+# */ -/* Updated: 2017/02/06 20:39:25 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:31:46 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,6 @@ int exec_if(t_btree **ast) { ft_exec(&(*ast)->right); - data_singleton()->script.lc = 0; // btree_delone(ast, &ast_free); return (0); } diff --git a/42sh/src/exec/exec_redir.c b/42sh/src/exec/exec_redir.c index e8245a67..6be7340c 100644 --- a/42sh/src/exec/exec_redir.c +++ b/42sh/src/exec/exec_redir.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 17:27:51 by jhalford #+# #+# */ -/* Updated: 2017/02/20 20:33:34 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:00:03 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/ft_exec.c b/42sh/src/exec/ft_exec.c index dd19e60d..a2d83114 100644 --- a/42sh/src/exec/ft_exec.c +++ b/42sh/src/exec/ft_exec.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/27 20:30:32 by jhalford #+# #+# */ -/* Updated: 2017/02/20 21:03:42 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:01:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,18 +20,19 @@ t_execmap g_execmap[] = {TK_SEMI, &exec_semi}, {TK_AMP, &exec_ampersand}, {TK_PIPE, &exec_pipe}, - {TK_LESS, &exec_less}, - {TK_GREAT, &exec_great}, - {TK_DGREAT, &exec_dgreat}, + {TK_LESS, &exec_redir}, + {TK_GREAT, &exec_redir}, + {TK_DLESS, &exec_redir}, + {TK_DGREAT, &exec_redir}, + {TK_LESSAND, &exec_redir}, + {TK_GREATAND, &exec_redir}, {TK_WHILE, &exec_while}, {TK_IF, &exec_if}, {TK_ELIF, &exec_elif}, {TK_ELSE, &exec_else}, {TK_UNTIL, &exec_until}, - {TK_COMMAND, &exec_command}, {TK_SUBSHELL, &exec_command}, - {TK_REDIR, &exec_redir}, - {TK_COMMAND | TK_SUBSHELL, &exec_command}, + {TK_COMMAND, &exec_command}, {0, 0}, }; @@ -48,7 +49,7 @@ int ft_exec(t_btree **ast) { if (item->type == g_execmap[i].type) { - DG("match : %s and %s", + DG("match : %s and %s", read_state(item->type), read_state(g_execmap[i].type)); /* return ((*g_execmap[i].f)(ast)); */ (*g_execmap[i].f)(ast); @@ -56,4 +57,4 @@ int ft_exec(t_btree **ast) i++; } return (0); - +} diff --git a/42sh/src/job-control/put_job_in_background.c b/42sh/src/job-control/put_job_in_background.c index 02357157..09f1b482 100644 --- a/42sh/src/job-control/put_job_in_background.c +++ b/42sh/src/job-control/put_job_in_background.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 15:03:29 by jhalford #+# #+# */ -/* Updated: 2017/01/31 15:09:06 by jhalford ### ########.fr */ +/* Updated: 2017/02/20 21:52:28 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/.ft_post_tokenize.c.swp b/42sh/src/lexer/.ft_post_tokenize.c.swp deleted file mode 100644 index a6c9da13..00000000 Binary files a/42sh/src/lexer/.ft_post_tokenize.c.swp and /dev/null differ diff --git a/42sh/src/lexer/.ft_tokenize.c.swp b/42sh/src/lexer/.ft_tokenize.c.swp deleted file mode 100644 index 7dab1dd1..00000000 Binary files a/42sh/src/lexer/.ft_tokenize.c.swp and /dev/null differ diff --git a/42sh/src/lexer/.reduce_bquotes.c.swp b/42sh/src/lexer/.reduce_bquotes.c.swp deleted file mode 100644 index 1f2cadf3..00000000 Binary files a/42sh/src/lexer/.reduce_bquotes.c.swp and /dev/null differ diff --git a/42sh/src/lexer/get_reserved_words.c b/42sh/src/lexer/get_reserved_words.c index a99b60db..7a24e372 100644 --- a/42sh/src/lexer/get_reserved_words.c +++ b/42sh/src/lexer/get_reserved_words.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 00:07:05 by ariard #+# #+# */ -/* Updated: 2017/02/20 18:54:01 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:06:20 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,12 +21,12 @@ int get_reserved_words(t_list **alst) temp = *alst; previous_token = NULL; while (temp) - { + { token = temp->content; if (!previous_token || (previous_token->type & RW_SEP)) { - if (token->type == TK_N_WORD) - { + if (token->type == TK_WORD) + { if (ft_strncmp(token->data, "while", 5) == 0) token->type = TK_WHILE; else if (ft_strncmp(token->data, "done", 4) == 0) diff --git a/42sh/src/lexer/lexer_backslash.c b/42sh/src/lexer/lexer_backslash.c index 4a8a8e4a..abd2a95c 100644 --- a/42sh/src/lexer/lexer_backslash.c +++ b/42sh/src/lexer/lexer_backslash.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/03 11:56:49 by jhalford #+# #+# */ -/* Updated: 2017/02/20 20:49:19 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:04:36 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_comment.c~HEAD b/42sh/src/lexer/lexer_comment.c~HEAD deleted file mode 100644 index 844bf507..00000000 --- a/42sh/src/lexer/lexer_comment.c~HEAD +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lexer_comment.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/24 18:22:35 by ariard #+# #+# */ -/* Updated: 2017/01/30 17:22:48 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "lexer.h" - -int lexer_comment(t_list **alst, char *str) -{ - t_token *token; - - (void)str; - token = (*alst)->content; - if (!token->type) - ft_lstdel(alst, &token_free); - return (0); -} diff --git a/42sh/src/lexer/lexer_lex.c b/42sh/src/lexer/lexer_lex.c index 9e888bcf..8e9a7720 100644 --- a/42sh/src/lexer/lexer_lex.c +++ b/42sh/src/lexer/lexer_lex.c @@ -5,13 +5,8 @@ /* +:+ +:+ +:+ */ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -<<<<<<< HEAD:src/lexer/ft_tokenize.c -/* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */ -/* Updated: 2017/02/17 17:28:23 by ariard ### ########.fr */ -======= /* Created: 2017/02/09 17:08:51 by jhalford #+# #+# */ -/* Updated: 2017/02/09 22:58:48 by jhalford ### ########.fr */ ->>>>>>> master:src/lexer/lexer_lex.c +/* Updated: 2017/02/20 21:55:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/lexer/lexer_newline.c~HEAD b/42sh/src/lexer/lexer_newline.c~HEAD deleted file mode 100644 index c18ac827..00000000 --- a/42sh/src/lexer/lexer_newline.c~HEAD +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lexer_newline.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/23 23:19:46 by ariard #+# #+# */ -/* Updated: 2017/02/03 19:53:03 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "lexer.h" - -int lexer_newline(t_list **alst, char *str) -{ - t_token *token; - - if (*alst) - { - token = (*alst)->content; - if (*token->data) - return (lexer_newline(&(*alst)->next, str)); - } - else - { - token = token_init(); - *alst = ft_lstnew(token, sizeof(*token)); - } - token = (*alst)->content; - token->type = TK_NEWLINE; - return (ft_tokenize(&(*alst)->next, str + 1, DEFAULT)); -} diff --git a/42sh/src/lexer/lexer_special.c b/42sh/src/lexer/lexer_special.c deleted file mode 100644 index 53f35075..00000000 --- a/42sh/src/lexer/lexer_special.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lexer_special.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/11 15:35:38 by jhalford #+# #+# */ -/* Updated: 2017/01/25 22:53:15 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "lexer.h" - -int lexer_special(t_list **alst, char *str) -{ - t_token *token; - t_list **lst; - - lst = alst; - if (*alst) - { - token = (*alst)->content; - if (token->type) - lst = &(*alst)->next; - } - token = token_init(); - *lst = ft_lstnew(token, sizeof(*token)); - token = (*lst)->content; - if (*str == '(') - token->type = TK_PAREN_OPEN; - else if (*str == ')') - token->type = TK_PAREN_CLOSE; - else if (*str == '`') - token->type = TK_BQUOTE; - token->data = str; - return (ft_tokenize(&(*lst)->next, str + 1, DEFAULT)); -} diff --git a/42sh/src/lexer/lexer_then.c b/42sh/src/lexer/lexer_then.c deleted file mode 100644 index c00c521c..00000000 --- a/42sh/src/lexer/lexer_then.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lexer_then.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/31 23:29:49 by ariard #+# #+# */ -/* Updated: 2017/02/10 01:15:01 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "lexer.h" - -int lexer_then(t_list **alst, char *str) -{ - t_token *token; - t_lexstate state; - - if (*alst) - return (lexer_then(&(*alst)->next, str)); - else - { - token = token_init(); - *alst = ft_lstnew(token, sizeof(*token)); - } - token = (*alst)->content; - token->type = TK_THEN; - state = TK_WORD; - return (ft_tokenize(&(*alst)->next, str + 4, state)); -} diff --git a/42sh/src/lexer/reduce_bquotes.c b/42sh/src/lexer/reduce_bquotes.c deleted file mode 100644 index 60915dcb..00000000 --- a/42sh/src/lexer/reduce_bquotes.c +++ /dev/null @@ -1,56 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* reduce_bquotes.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/11 16:46:27 by jhalford #+# #+# */ -/* Updated: 2017/02/03 14:36:25 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "lexer.h" - -int reduce_bquotes(t_list **alst, char **str) -{ - t_list *start; - t_list **end; - t_token *token; - int tk; - char *new; - char *fit; - char *bq_start; - char *bq_end; - - tk = TK_BQUOTE; - DG("check 0"); - if ((start = ft_lst_find(*alst, &tk, token_cmp_type))) - { - DG("check 1"); - end = &start->next; - while (end && *end) - { - token = (*end)->content; - if (token->type == TK_BQUOTE) - break ; - end = &(*end)->next; - } - if (!*end) - { - DG("check 42"); - return (-1); - } - bq_start = ((t_token*)start->content)->data; - bq_end = ((t_token*)(*end)->content)->data; - ft_lstdel(end, token_free); - fit = command_getoutput(ft_strbetween(bq_start + 1, bq_end)); - new = ft_strreplace(str, bq_start, bq_end, fit); - ft_strdel(str); - *str = new; - ft_lstdel(alst, token_free); - ft_tokenize(alst, new, DEFAULT); - return (1); - } - return (0); -} diff --git a/42sh/src/lexer/reduce_parens.c b/42sh/src/lexer/reduce_parens.c deleted file mode 100644 index 9df6e40d..00000000 --- a/42sh/src/lexer/reduce_parens.c +++ /dev/null @@ -1,50 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* reduce_parens.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/11 16:13:31 by jhalford #+# #+# */ -/* Updated: 2017/02/20 20:55:06 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "lexer.h" - -int reduce_parens(t_list **alst, char *str) -{ - t_list *start; - t_list *end; - t_token *token; - int num_p; - int tk; - - (void)str; - tk = TK_PAREN_OPEN; - if ((start = ft_lst_find(*alst, &tk, token_cmp_type))) - { - end = start->next; - num_p = 1; - while (end) - { - token = end->content; - if (token->type == TK_PAREN_OPEN) - num_p++; - else if (token->type == TK_PAREN_CLOSE) - num_p--; - if (num_p == 0) - break ; - end = end->next; - ft_lst_delif(alst, token, ft_addrcmp, token_free); - } - if (!end) - return (-1); - token = start->content; - token->type = TK_SUBSHELL; - token->data = ft_strbetween(token->data + 1, ((t_token*)end->content)->data); - ft_lst_delif(alst, end->content, ft_addrcmp, token_free); - return (1); - } - return (0); -} diff --git a/42sh/src/lexer/stack_to_prompt.c b/42sh/src/lexer/stack_to_prompt.c index 3a5cc8ff..77defb31 100644 --- a/42sh/src/lexer/stack_to_prompt.c +++ b/42sh/src/lexer/stack_to_prompt.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 21:25:26 by jhalford #+# #+# */ -/* Updated: 2017/02/17 14:41:08 by jhalford ### ########.fr */ +/* Updated: 2017/02/20 22:13:54 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/.main.c.swp b/42sh/src/main/.main.c.swp deleted file mode 100644 index cb0bbd5e..00000000 Binary files a/42sh/src/main/.main.c.swp and /dev/null differ diff --git a/42sh/src/main/ft_cleanup.c b/42sh/src/main/ft_cleanup.c deleted file mode 100644 index 7cf6aa3b..00000000 --- a/42sh/src/main/ft_cleanup.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_cleanup.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/01 14:42:42 by jhalford #+# #+# */ -/* Updated: 2016/12/09 21:50:38 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -extern char **environ; -extern char PC; -extern char *UP; -extern char *BC; - -void ft_cleanup(void) -{ - struct termios term; - - DG("cleanup. char * UP at %p", UP); - DG("cleanup. char * BC at %p", BC); - if (tcgetattr(0, &term) == -1) - return ; - term.c_lflag |= ICANON | ISIG | ECHO; - if (tcsetattr(0, TCSANOW, &term) == -1) - return ; -} diff --git a/42sh/src/main/ft_putast.c b/42sh/src/main/ft_putast.c index 02ad0f73..cd109ab4 100644 --- a/42sh/src/main/ft_putast.c +++ b/42sh/src/main/ft_putast.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */ -/* Updated: 2017/02/20 16:42:40 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:19:40 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,8 +28,8 @@ char *ft_putast(void *nodein) return ("TK_DO"); else if (node->type == TK_AMP) return (" & "); - else if (node->type == TK_N_WORD) - return (" TK_N_WORD"); + else if (node->type == TK_WORD) + return (" TK_WORD"); else if (node->type == TK_SEMI) return (" ; "); else if (node->type == TK_AND_IF) diff --git a/42sh/src/main/ft_putast2.c b/42sh/src/main/ft_putast2.c index 35668b46..d1bcb89b 100644 --- a/42sh/src/main/ft_putast2.c +++ b/42sh/src/main/ft_putast2.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/14 18:18:04 by jhalford #+# #+# */ -/* Updated: 2017/02/05 22:48:44 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:08:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,7 +27,7 @@ void ft_putast2(void *nodein) ft_sstrprint_fd(2, node->data.sstr, ','); ft_putchar_fd('\n', 2); } - else if (node->type & TK_REDIR) + else if (TK_REDIR(node->type)) { ft_putnbr_fd(node->data.redir.n, 2); if (node->type == TK_GREATAND || node->type == TK_LESSAND) diff --git a/42sh/src/main/lib_expansion.c b/42sh/src/main/lib_expansion.c deleted file mode 100644 index 8905c284..00000000 --- a/42sh/src/main/lib_expansion.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* lib_expansion.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/03 13:37:41 by jhalford #+# #+# */ -/* Updated: 2016/12/03 13:37:41 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -void ft_expand_dollar(char **av, char **env) -{ - char *dollar; - - while (*av) - { - if ((dollar = ft_strchr(*av, '$'))) - { - *dollar = '\0'; - *av = ft_strjoin(*av, ft_getenv(env, dollar + 1)); - } - av++; - } -} diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 2db727e0..5bce1e37 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/02/20 20:59:49 by ariard ### ########.fr */ +/* Updated: 2017/02/20 21:52:34 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/read_script.c b/42sh/src/main/read_script.c deleted file mode 100644 index 71e39750..00000000 --- a/42sh/src/main/read_script.c +++ /dev/null @@ -1,67 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_read_script.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/21 22:49:31 by ariard #+# #+# */ -/* Updated: 2017/02/06 22:05:31 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -int get_script_content(t_script *script) -{ - char *line; - - line = NULL; - while (((get_next_line(script->fd, &line))) > 0) - { - ft_strappend(&script->buffer, line); - ft_strappend(&script->buffer, "\n"); - ft_strdel(&line); - script->size += ft_strlen(script->buffer); - } - if (script->size) - script->buffer[ft_strlen(script->buffer) - 1] = 0; - return (script->size); -} - -static int rs_read(char *file, t_script *script) -{ - if ((script->fd = open(file, O_RDONLY)) == -1) - return (0); - get_script_content(script); - if (script->size > 0) - { - data_singleton()->opts &= ~SHELL_MODE_MASK; - data_singleton()->opts |= SHELL_MODE_SCRIPT; - } - return (0); -} - -static int rs_setup(t_script *script) -{ - ft_bzero(script, sizeof(script)); - script->buffer = NULL; - script->size = 0; - script->fd = -1; - return (0); -} - -int read_script(char *file) -{ - t_script *script; - - script = &data_singleton()->script; - if (!file) - return (0); - if (rs_setup(script) < 0) - return (-1); - if (rs_read(file, script) < 0) - return (-1); - DG("{inv}{bol}{gre}read of script{eoc} script detected"); - return (1); -} diff --git a/42sh/src/main/remove_trailing_esc_nl.c b/42sh/src/main/remove_trailing_esc_nl.c deleted file mode 100644 index 9d6fb232..00000000 --- a/42sh/src/main/remove_trailing_esc_nl.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* remove_trailing_esc_nl.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/02/09 16:52:34 by jhalford #+# #+# */ -/* Updated: 2017/02/09 17:00:33 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -int remove_trailing_esc_nl(char *str) -{ - char *last; - - last = str + ft_strlen(str) - 1; - if (*last == '\\') - { - *last = 0; - return (1); - } - return (0); -} diff --git a/42sh/src/main/shell_script.c b/42sh/src/main/shell_script.c deleted file mode 100644 index 32f9899d..00000000 --- a/42sh/src/main/shell_script.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* shell_script.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: ariard +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/22 23:06:34 by ariard #+# #+# */ -/* Updated: 2017/02/19 16:02:17 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -int shell_script() -{ - t_list *token; - t_btree *ast; - t_list *list_ast; - t_script *script; - - token = NULL; - ast = NULL; - list_ast = NULL; - script = &data_singleton()->script; - while (script->size) - { - if (ft_lexer(&token, &data_singleton()->script.buffer) || !token) - return (1); - DG("after post_tokenize"); - token_print(token); - if (ft_parse2(&ast, &token)) - return (1); -// btree_print(STDBUG, ast, &ft_putast); -// if (ft_exec(&ast)) -// return (1); - ast = NULL; - script->size = 0; - get_script_content(script); - } - close(script->fd); - return (0); -} diff --git a/42sh/src/main/sig_handler.c b/42sh/src/main/sig_handler.c deleted file mode 100644 index d56b03ee..00000000 --- a/42sh/src/main/sig_handler.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* sig_handler.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/01 12:43:22 by jhalford #+# #+# */ -/* Updated: 2016/12/03 13:31:33 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -pid_t g_pid; - -void sig_handler(int signo) -{ - (void)signo; - if (signo == SIGINT) - { - if (g_pid) - kill(g_pid, SIGINT); - if (kill(g_pid, 0) == 0) - ft_putendl(""); - } -} diff --git a/42sh/src/parser/add_cmd.c b/42sh/src/parser/add_cmd.c index 31c7ba6e..23bf28bf 100644 --- a/42sh/src/parser/add_cmd.c +++ b/42sh/src/parser/add_cmd.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 20:49:15 by ariard #+# #+# */ -/* Updated: 2017/02/20 18:19:04 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:27:06 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,7 +22,7 @@ int add_cmd(t_btree **ast, t_list **lst) if (!*ast) gen_node(ast); else if (isdir(ast)) - return (add_file(ast, lst)); + return (add_file(ast, lst)); else if (isloop(ast)) return (add_loop_cmd(ast, lst)); else if (iscondition(ast, lst) == 1) @@ -35,7 +35,7 @@ int add_cmd(t_btree **ast, t_list **lst) token = (*lst)->content; node = (*ast)->item; node->type = token->type; - if (token->type == TK_N_WORD) + if (token->type == TK_WORD) { my_tab = ft_sstradd(my_tab, token->data); my_tab = ft_sstradd(my_tab, (char *)token->esc); diff --git a/42sh/src/parser/build_tree.c b/42sh/src/parser/build_tree.c index 1718fdad..b602bead 100644 --- a/42sh/src/parser/build_tree.c +++ b/42sh/src/parser/build_tree.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 18:32:59 by ariard #+# #+# */ -/* Updated: 2017/02/20 19:03:03 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:16:04 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,7 @@ t_treematch g_treematch[] = { - {TK_N_WORD, &add_cmd}, + {TK_WORD, &add_cmd}, {TK_PIPE, &add_sep}, {TK_SEMI, &add_sep}, {TK_GREAT, &add_sep}, @@ -36,8 +36,8 @@ t_treematch g_treematch[] = static int isseparator(int type, int cache) { - if (type == TK_NEWLINE && (cache == TK_WHILE || cache == TK_DO - || cache == TK_NEWLINE || cache == TK_THEN)) + if (type == TK_NEWLINE && (cache == TK_WHILE || cache == TK_DO + || cache == TK_NEWLINE || cache == TK_THEN)) return (0); return (1); } @@ -53,13 +53,13 @@ int build_tree(t_btree **ast, t_list **lst) while (g_treematch[i].type) { if (g_treematch[i].type == token->type - && isseparator(token->type, cache)) + && isseparator(token->type, cache)) { - + DG("func TK : '%s' TK : '%s'", - read_state(g_treematch[i].type) ,read_state(token->type)); + read_state(g_treematch[i].type) ,read_state(token->type)); cache = token->type; - return (g_treematch[i].add(ast, lst)); + return (g_treematch[i].add(ast, lst)); } i++; } diff --git a/42sh/src/parser/eval_sym.c b/42sh/src/parser/eval_sym.c index 53ee98e6..f1184bb5 100644 --- a/42sh/src/parser/eval_sym.c +++ b/42sh/src/parser/eval_sym.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 16:26:30 by ariard #+# #+# */ -/* Updated: 2017/02/20 19:26:28 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:20:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,11 +14,11 @@ t_stackmatch g_stackmatch[] = { - {TK_N_WORD, CMD_SUFFIX}, - {TK_N_WORD, TK_PIPE}, - {TK_N_WORD, TK_CASE}, - {TK_N_WORD, WORDLIST}, - {TK_N_WORD, LINEBREAK}, + {TK_WORD, CMD_SUFFIX}, + {TK_WORD, TK_PIPE}, + {TK_WORD, TK_CASE}, + {TK_WORD, WORDLIST}, + {TK_WORD, LINEBREAK}, {TK_ASSIGNEMENT_WORD, CMD_PREFIX}, {TK_IO_NUMBER, REDIRECT_LIST}, {TK_IO_NUMBER, CMD_SUFFIX}, @@ -187,7 +187,7 @@ t_stackmatch g_stackmatch[] = {TK_ELIF, COMPLETE_CONDITION}, {TK_ELIF, CONDITION}, {TK_FI, ELSE_PART}, - {TK_FI, COMPOUND_LIST}, + {TK_FI, COMPOUND_LIST}, {TK_FI, CMD_SUPERIOR}, {TK_FI, END_COMMAND}, {TK_FI, CONDITION}, @@ -291,7 +291,7 @@ t_stackmatch g_stackmatch[] = {SEPARATOR_OP, COMPOUND_LIST}, {SEPARATOR_OP, PIPE_SEMI_SEQUENCE}, {LINEBREAK, TK_SEMI}, - {LINEBREAK, SEPARATOR_OP}, + {LINEBREAK, SEPARATOR_OP}, {LINEBREAK, TK_PAREN_CLOSE}, {LINEBREAK, WORD}, {LINEBREAK, IN}, @@ -318,7 +318,7 @@ t_stackmatch g_stackmatch[] = {NEWLINE_LIST, WORDLIST}, {NEWLINE_LIST, TERM}, {NEWLINE_LIST, COMPOUND_LIST}, - {NEWLINE_LIST, COMPLETE_COMMANDS}, + {NEWLINE_LIST, COMPLETE_COMMANDS}, {NEWLINE_LIST, COMPLETE_CONDITION}, {NEWLINE_LIST, CONDITION}, {HERE_END, TK_DLESS}, @@ -390,7 +390,7 @@ t_stackmatch g_stackmatch[] = {CMD_NAME, TK_ELSE}, {CMD_NAME, COMPOUND_LIST}, {CMD_NAME, COMPLETE_CONDITION}, - + {CMD_SUPERIOR, TK_WHILE}, {CMD_SUPERIOR, TK_UNTIL}, {CMD_SUPERIOR, TK_DO}, @@ -407,7 +407,7 @@ t_stackmatch g_stackmatch[] = {CMD_SUPERIOR, TK_PIPE}, {CMD_SUPERIOR, PIPE_SEMI_SEQUENCE}, {CMD_SUPERIOR, AND_OR_MAJOR}, - + {SIMPLE_COMMAND, TK_WHILE}, {SIMPLE_COMMAND, TK_UNTIL}, {SIMPLE_COMMAND, TK_DO}, diff --git a/42sh/src/parser/ft_parse.c b/42sh/src/parser/ft_parse.c index 4d1a3c7d..dc8a97c3 100644 --- a/42sh/src/parser/ft_parse.c +++ b/42sh/src/parser/ft_parse.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */ -/* Updated: 2017/02/20 21:01:51 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:39:39 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,7 +26,7 @@ static int end_instruction(t_sym sym) return (0); } -int ft_parse2(t_btree **ast, t_list **token) +int ft_parse(t_btree **ast, t_list **token) { t_sym *new_sym; t_sym *stack; diff --git a/42sh/src/parser/old_parse.c b/42sh/src/parser/old_parse.c deleted file mode 100644 index af5cb658..00000000 --- a/42sh/src/parser/old_parse.c +++ /dev/null @@ -1,58 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_parse.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/30 17:14:58 by jhalford #+# #+# */ -/* Updated: 2017/02/15 19:56:09 by ariard ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "parser.h" - -t_parser g_parser[] = -{ - {TK_AND_IF | TK_OR_IF, &parse_separator}, - {TK_AMP, &parse_separator}, - {TK_PIPE, &parse_separator}, - {TK_LESS, &parse_less}, - {TK_GREAT, &parse_great}, - {TK_DLESS, &parse_dless}, - {TK_DGREAT, &parse_dgreat}, - {TK_LESSAND, &parse_lessand}, - {TK_GREATAND, &parse_greatand}, - {TK_SUBSHELL, &parse_subshell}, - {TK_N_WORD, &parse_word}, - {0, 0}, -}; - -int ft_parse(t_btree **ast, t_list **start) -{ - t_list *lst; - t_astnode item; - int i; - - DG("old parser"); - i = 0; - if (!*start) - return (0); - if (!*ast) - { - *ast = btree_create_node(&item, sizeof(item)); - ((t_astnode *)(*ast)->item)->data.token = NULL; - ((t_astnode *)(*ast)->item)->type = 0; - } - while (g_parser[i].type) - { - if ((lst = ft_lst_find(*start, &g_parser[i].type, &token_cmp_type))) - { - if (g_parser[i].f) - (*g_parser[i].f)(ast, start, &lst); - return (0); - } - i++; - } - return (0); -} diff --git a/42sh/src/parser/produce_sym.c b/42sh/src/parser/produce_sym.c index 5807c61d..306c9db1 100644 --- a/42sh/src/parser/produce_sym.c +++ b/42sh/src/parser/produce_sym.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 17:58:34 by ariard #+# #+# */ -/* Updated: 2017/02/20 18:50:16 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:37:22 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,38 +14,38 @@ t_prodmatch g_prodmatch[] = { - {TK_N_WORD, TK_DLESS, HERE_END}, - {TK_N_WORD, TK_DLESSDASH, HERE_END}, - {TK_N_WORD, TK_LESS, FILENAME}, - {TK_N_WORD, TK_LESSAND, FILENAME}, - {TK_N_WORD, TK_GREAT, FILENAME}, - {TK_N_WORD, TK_GREATAND, FILENAME}, - {TK_N_WORD, TK_DGREAT, FILENAME}, - {TK_N_WORD, TK_LESSGREAT, FILENAME}, - {TK_N_WORD, TK_CLOBBER, FILENAME}, - {TK_N_WORD, CMD_WORD, CMD_SUFFIX}, - {TK_N_WORD, CMD_NAME, CMD_SUFFIX}, - {TK_N_WORD, CMD_SUPERIOR, CMD_SUFFIX}, - {TK_N_WORD, LINEBREAK, CMD_NAME}, - {TK_N_WORD, TK_PIPE, CMD_NAME}, - {TK_N_WORD, AND_OR, CMD_NAME}, - {TK_N_WORD, AND_OR_MAJOR, CMD_NAME}, - {TK_N_WORD, TK_WHILE, CMD_NAME}, - {TK_N_WORD, TK_UNTIL, CMD_NAME}, - {TK_N_WORD, TK_DO, CMD_NAME}, - {TK_N_WORD, TK_IF, CMD_NAME}, - {TK_N_WORD, TK_THEN, CMD_NAME}, - {TK_N_WORD, TK_ELIF, CMD_NAME}, - {TK_N_WORD, TK_ELSE, CMD_NAME}, - {TK_N_WORD, COMPOUND_LIST, CMD_NAME}, - {TK_N_WORD, COMPLETE_CONDITION, CMD_NAME}, - {TK_N_WORD, NEWLINE_LIST, CMD_NAME}, - {TK_N_WORD, TK_BANG, CMD_NAME}, - {TK_N_WORD, PIPE_SEMI_SEQUENCE, CMD_NAME}, - {TK_N_WORD, SEPARATOR_OP, CMD_NAME}, - {TK_N_WORD, IN, WORDLIST}, - {TK_N_WORD, CASE_LIST, PATTERN}, - {TK_N_WORD, TK_PAREN_OPEN, PATTERN}, + {TK_WORD, TK_DLESS, HERE_END}, + {TK_WORD, TK_DLESSDASH, HERE_END}, + {TK_WORD, TK_LESS, FILENAME}, + {TK_WORD, TK_LESSAND, FILENAME}, + {TK_WORD, TK_GREAT, FILENAME}, + {TK_WORD, TK_GREATAND, FILENAME}, + {TK_WORD, TK_DGREAT, FILENAME}, + {TK_WORD, TK_LESSGREAT, FILENAME}, + {TK_WORD, TK_CLOBBER, FILENAME}, + {TK_WORD, CMD_WORD, CMD_SUFFIX}, + {TK_WORD, CMD_NAME, CMD_SUFFIX}, + {TK_WORD, CMD_SUPERIOR, CMD_SUFFIX}, + {TK_WORD, LINEBREAK, CMD_NAME}, + {TK_WORD, TK_PIPE, CMD_NAME}, + {TK_WORD, AND_OR, CMD_NAME}, + {TK_WORD, AND_OR_MAJOR, CMD_NAME}, + {TK_WORD, TK_WHILE, CMD_NAME}, + {TK_WORD, TK_UNTIL, CMD_NAME}, + {TK_WORD, TK_DO, CMD_NAME}, + {TK_WORD, TK_IF, CMD_NAME}, + {TK_WORD, TK_THEN, CMD_NAME}, + {TK_WORD, TK_ELIF, CMD_NAME}, + {TK_WORD, TK_ELSE, CMD_NAME}, + {TK_WORD, COMPOUND_LIST, CMD_NAME}, + {TK_WORD, COMPLETE_CONDITION, CMD_NAME}, + {TK_WORD, NEWLINE_LIST, CMD_NAME}, + {TK_WORD, TK_BANG, CMD_NAME}, + {TK_WORD, PIPE_SEMI_SEQUENCE, CMD_NAME}, + {TK_WORD, SEPARATOR_OP, CMD_NAME}, + {TK_WORD, IN, WORDLIST}, + {TK_WORD, CASE_LIST, PATTERN}, + {TK_WORD, TK_PAREN_OPEN, PATTERN}, {TK_ASSIGNEMENT_WORD, LINEBREAK, CMD_PREFIX}, {TK_ASSIGNEMENT_WORD, TK_BANG, CMD_PREFIX}, {TK_ASSIGNEMENT_WORD, SEPARATOR_OP, CMD_PREFIX}, diff --git a/42sh/src/parser/read_stack.c b/42sh/src/parser/read_stack.c index b13bc4ca..95f5c3a1 100644 --- a/42sh/src/parser/read_stack.c +++ b/42sh/src/parser/read_stack.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/09 15:32:10 by ariard #+# #+# */ -/* Updated: 2017/02/20 18:50:22 by ariard ### ########.fr */ +/* Updated: 2017/02/20 22:38:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -73,7 +73,7 @@ char *read_state(t_sym current) if (current == AND_OR_MINOR) return("AND_OR_MINOR"); if (current == AND_OR_MAJOR) - return ("AND_OR_MAJOR"); + return ("AND_OR_MAJOR"); if (current == TK_COMMAND) return ("TK_COMMAND"); if (current == TK_AND_IF) @@ -104,7 +104,7 @@ char *read_state(t_sym current) return ("CMD_SUPERIOR"); if (current == TK_IO_NUMBER) return ("IO_NUMBER"); - if (current == CMD_SUFFIX) + if (current == CMD_SUFFIX) return ("CMD_SUFFIX"); if (current == CMD_PREFIX) return ("CMD_PREFIX"); @@ -132,7 +132,7 @@ char *read_state(t_sym current) return ("COMPLETE_COMMAND"); if (current == COMPLETE_COMMANDS) return ("COMPLETE_COMMANDS"); - if (current == TK_N_WORD) + if (current == TK_WORD) return ("TK_WORD"); if (current == CMD_NAME) return ("CMD_NAME"); @@ -159,7 +159,7 @@ char *read_state(t_sym current) return ("NULL"); } -int ft_read_stack(t_sym *stack) +int ft_read_stack(t_sym *stack) { while (*stack) {