From b15ab562d74b5111ac7c9bd6e0ec185435902472 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 31 Mar 2020 21:41:33 +0200 Subject: Removing ms_ prefix, Removing junk --- include/eval.h | 44 +++++++++++++++++++++++++ include/minishell.h | 25 +++++++-------- include/ms_eval.h | 43 ------------------------- include/ms_parse.h | 92 ----------------------------------------------------- include/parse.h | 48 ++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 149 deletions(-) create mode 100644 include/eval.h delete mode 100644 include/ms_eval.h delete mode 100644 include/ms_parse.h create mode 100644 include/parse.h (limited to 'include') diff --git a/include/eval.h b/include/eval.h new file mode 100644 index 0000000..ec04ff5 --- /dev/null +++ b/include/eval.h @@ -0,0 +1,44 @@ +#ifndef MS_EVAL_H +# define MS_EVAL_H + +/** +** \file eval.h +** \brief Evaluation module +*/ + +# include "minishell.h" +# include "ast.h" + +/** +** \brief Evaluation state struct +*/ + +typedef struct +{ + int status; + int in_pipe[2]; // need stack pipe + int out_pipe[2]; + t_path path; + t_env env; +} t_eval_state; + +/** +** \brief Evaluation status struct +*/ + +typedef struct +{ + char *err; + int status; +} t_eval_status; + + +/** +** \brief Evaluate an AST +** \param state State of the evaluation +** \param ast Abstract syntax tree to evaluate +*/ + +int eval(t_eval_state *state, t_ast *ast); + +#endif diff --git a/include/minishell.h b/include/minishell.h index 6a00ca8..4f33951 100644 --- a/include/minishell.h +++ b/include/minishell.h @@ -34,9 +34,6 @@ # include "libft_lst.h" # include "libft_util.h" -# include "ms_parse.h" -// # include "ms_eval.h" - /** ** \brief Value of pipe entry if closed */ @@ -62,31 +59,31 @@ typedef t_ftht* t_env; ** path.c */ -t_path ms_path_update(t_path path, char *path_var); +t_path path_update(t_path path, char *path_var); /* ** env.c */ -t_env ms_env_from_array(char **envp); -char **ms_env_to_array(t_env env); +t_env env_from_array(char **envp); +char **env_to_array(t_env env); /* ** builtin*.c - directory with all builtin commands */ -int ms_echo(char **argv); -int ms_cd(t_env env, char **argv); -int ms_pwd(void); -int ms_export(t_env env, char **argv); -int ms_unset(t_env env, char **argv); -int ms_env(t_env env); -int ms_exit(void); +int builtin_echo(char **argv); +int builtin_cd(t_env env, char **argv); +int builtin_pwd(void); +int builtin_export(t_env env, char **argv); +int builtin_unset(t_env env, char **argv); +int builtin_env(t_env env); +int builtin_exit(void); /* ** util.c - various utilitary functions */ -void ms_ht_del_str_entry(t_ftht_entry *entry); +void ht_del_str_entry(t_ftht_entry *entry); #endif diff --git a/include/ms_eval.h b/include/ms_eval.h deleted file mode 100644 index b53b845..0000000 --- a/include/ms_eval.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef MS_EVAL_H -# define MS_EVAL_H - -/** -** \file ms_eval.h -** \brief Evaluation module -*/ - -# include "minishell.h" - -/** -** \brief Evaluation state struct -*/ - -typedef struct -{ - int status; - int in_pipe[2]; // need stack pipe - int out_pipe[2]; - t_path path; - t_env env; -} t_eval_state; - -/** -** \brief Evaluation status struct -*/ - -typedef struct -{ - char *err; - int status; -} t_eval_status; - - -/** -** \brief Evaluate an AST -** \param state State of the evaluation -** \param ast Abstract syntax tree to evaluate -*/ - -int ms_eval(t_eval_state *state, t_ast *ast); - -#endif diff --git a/include/ms_parse.h b/include/ms_parse.h deleted file mode 100644 index 0a33ccf..0000000 --- a/include/ms_parse.h +++ /dev/null @@ -1,92 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ms_parse.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/28 09:00:00 by cacharle #+# #+# */ -/* Updated: 2020/02/28 14:57:58 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef MS_PARSE_H -# define MS_PARSE_H - -# include "minishell.h" -# include "ast.h" - -/** -** \file ms_parse.h -** \brief Input parsing and AST manipulation -** -** Context free grammar: -** ``` -** redir_in ::= '<' -** redir_out ::= '>' -** redir_append ::= '>>' -** string ::= '\'' .+ '\'' | '"' .+ '"' | [^ ]+ -** sep ::= '&&' | '||' | '|' | ';' -** expr ::= | | | -** cmd ::= + -** line ::= | -** ``` -*/ - -/** -** \brief AST node tag -** \param TAG_STRING string -** \param TAG_SEP `;` | `|` | `&&` | `||` -** \param TAG_REDIR_OUT `>` -** \param TAG_REDIR_IN `<` -** \param TAG_REDIR_APPEND `>>` -*/ - -// typedef enum -// { -// TAG_STRING, -// TAG_SEP, -// TAG_REDIR_OUT, -// TAG_REDIR_IN, -// TAG_REDIR_APPEND, -// TAG_CMD, -// TAG_LINE, -// } t_ast_tag; - -/** -** \brief AST (Abstract Syntax Tree) -** \param tag tag (type) of node -** \param content substring of the parsed string which corespond to tag -** \param children_num number of children -** \param children children nodes -*/ - -// typedef struct s_ast -// { -// t_tag tag; -// char* content; -// int children_num; -// struct s_ast** children; -// } t_ast; - -/* -** lexer.c -*/ - -char **ms_lexer(char *input); - -/* -** parse.c -*/ - -t_ast *ms_parse(char *input); - -/* -** ast.c -*/ - -// t_ast *ms_ast_new(t_tag tag); -// void ms_ast_destroy(t_ast *ast); -// void ms_ast_iter(t_ast *ast, void (*f)(void *f_arg, t_ast *children), void *arg); - -#endif diff --git a/include/parse.h b/include/parse.h new file mode 100644 index 0000000..c9710d7 --- /dev/null +++ b/include/parse.h @@ -0,0 +1,48 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* parse.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/28 09:00:00 by cacharle #+# #+# */ +/* Updated: 2020/02/28 14:57:58 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef MS_PARSE_H +# define MS_PARSE_H + +# include "minishell.h" +# include "ast.h" + +/** +** \file parse.h +** \brief Input parsing and AST manipulation +** +** Context free grammar: +** ``` +** redir_in ::= '<' +** redir_out ::= '>' +** redir_append ::= '>>' +** string ::= '\'' .+ '\'' | '"' .+ '"' | [^ ]+ +** sep ::= '&&' | '||' | '|' | ';' +** expr ::= | | | +** cmd ::= + +** line ::= | +** ``` +*/ + +/* +** lexer.c +*/ + +char **lexer(char *input); + +/* +** parse.c +*/ + +t_ast *parse(char *input); + +#endif -- cgit