From ae510a886b202926b4a5502de02a938054844ad4 Mon Sep 17 00:00:00 2001 From: nass1pro Date: Wed, 17 Jun 2020 19:01:25 +0200 Subject: Update line op --- include/ast.h | 13 +++++++------ include/eval.h | 6 +++--- include/parser.h | 5 +++-- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/ast.h b/include/ast.h index bcb5e11..317e1b8 100644 --- a/include/ast.h +++ b/include/ast.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* ast.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: charles +#+ +:+ +#+ */ +/* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:05:38 by charles #+# #+# */ -/* Updated: 2020/06/14 17:47:10 by charles ### ########.fr */ +/* Updated: 2020/06/17 16:43:12 by nahaddac ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,12 +33,12 @@ struct s_ast; */ -typedef struct s_line +typedef struct s_op { struct s_ast *left; struct s_ast *right; enum e_token_tag sep; -} t_line; +} t_op; /* ** \brief AST node tag (type) @@ -49,7 +49,8 @@ typedef struct s_line enum e_ast_tag { AST_CMD, - AST_LINE, + AST_OP, + AST_OP_PARENT, }; /* @@ -67,7 +68,7 @@ typedef struct s_ast enum e_ast_tag tag; union { - t_line line; + t_op op; t_ftlst *cmd_argv; }; t_ftlst *redirs; diff --git a/include/eval.h b/include/eval.h index f834d45..bde0cd7 100644 --- a/include/eval.h +++ b/include/eval.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* eval.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: charles +#+ +:+ +#+ */ +/* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/01 17:05:30 by charles #+# #+# */ -/* Updated: 2020/06/15 11:09:49 by charles ### ########.fr */ +/* Updated: 2020/06/17 15:49:49 by nahaddac ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,7 +44,7 @@ typedef struct s_eval_status typedef struct { t_eval_state *state; - t_line *line; + t_op *op; int fd_in; int fd_out; } t_fork_param_line; diff --git a/include/parser.h b/include/parser.h index 2bfa9d5..bc1e549 100644 --- a/include/parser.h +++ b/include/parser.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* parser.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: cacharle +#+ +:+ +#+ */ +/* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/28 09:00:00 by cacharle #+# #+# */ -/* Updated: 2020/06/14 10:31:20 by charles ### ########.fr */ +/* Updated: 2020/06/17 18:03:33 by nahaddac ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,6 +38,7 @@ */ t_ret *parse(t_ftlst *input); +t_ret *parse_c(t_ftlst *input); t_ast *push_cmd(t_ast *ast, t_ftlst *ret); t_ast *push_redir(t_ast *ast, t_ftlst *rest); -- cgit From 9a11d78abf7dc8fb8c8f3430538e80622a7854d3 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 17 Jun 2020 20:47:59 +0200 Subject: Show nass the power of parser combinator --- include/lexer.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/lexer.h b/include/lexer.h index b0e7f65..43c3821 100644 --- a/include/lexer.h +++ b/include/lexer.h @@ -24,6 +24,7 @@ enum e_token_tag TAG_IS_STR = TAG_STR | TAG_STR_SINGLE | TAG_STR_DOUBLE, TAG_IS_REDIR = TAG_REDIR_IN | TAG_REDIR_OUT | TAG_REDIR_APPEND, + TAG_IS_SEP = TAG_AND | TAG_END | TAG_OR | TAG_PIPE, }; typedef struct -- cgit From 4d5e2f861331989f8de16e3b0458e45b34bd0b6f Mon Sep 17 00:00:00 2001 From: nass1pro Date: Thu, 18 Jun 2020 13:19:21 +0200 Subject: Change parse --- include/parser.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/parser.h b/include/parser.h index bc1e549..302c45f 100644 --- a/include/parser.h +++ b/include/parser.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/28 09:00:00 by cacharle #+# #+# */ -/* Updated: 2020/06/17 18:03:33 by nahaddac ### ########.fr */ +/* Updated: 2020/06/18 13:18:13 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,11 +37,20 @@ ** parse.c */ + t_ret *parse(t_ftlst *input); -t_ret *parse_c(t_ftlst *input); +t_ret *parse_op(t_ftlst *input); +t_ret *parse_expr(t_ftlst *input); +t_ret *parse_cmd(t_ftlst *input); + +// utils +t_ret *ret_wrap_ast(t_ast *ast, t_ftlst *rest); +t_ftlst *push_token(t_ftlst **tokens, t_token *pushed); + + + t_ast *push_cmd(t_ast *ast, t_ftlst *ret); t_ast *push_redir(t_ast *ast, t_ftlst *rest); - int parse_cmd_str_true_false(enum e_token_tag tag); int parse_redir_true_false(enum e_token_tag tag); -- cgit