diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-03-31 21:31:26 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-03-31 21:31:26 +0200 |
| commit | 808d1499f5708ad4eda3612416e62efe6fdff021 (patch) | |
| tree | 1a2da935d99724de64dfc9b77347c1f5805d9256 /include/ms_eval.h | |
| parent | 941099778b59da6b904c284e8a82affe4766124b (diff) | |
| download | minishell-808d1499f5708ad4eda3612416e62efe6fdff021.tar.gz minishell-808d1499f5708ad4eda3612416e62efe6fdff021.tar.bz2 minishell-808d1499f5708ad4eda3612416e62efe6fdff021.zip | |
More specific AST struct and evaluation start
Diffstat (limited to 'include/ms_eval.h')
| -rw-r--r-- | include/ms_eval.h | 71 |
1 files changed, 19 insertions, 52 deletions
diff --git a/include/ms_eval.h b/include/ms_eval.h index 12c2b7e..b53b845 100644 --- a/include/ms_eval.h +++ b/include/ms_eval.h @@ -6,71 +6,38 @@ ** \brief Evaluation module */ -/* -** arg: -** type ARG -** value string -** -** redir in: -** type REDIRIN -** value fd -** -** redir out: -** type REDIROUT -** value fd -** -** redir append: -** type REDIRAPPEND -** value fd -*/ +# include "minishell.h" /** -** \enum t_val_type -** \brief A type for an evaluation node -** -** \param VAL_ERR error -** \param VAL_ERR argument -** \param VAL_REDIR redirection -** \param VAL_SEXPR S-expression +** \brief Evaluation state struct */ -typedef enum +typedef struct { - VAL_ERR, - VAL_ARG, - VAL_EXEC, - VAL_REDIR_IN, - VAL_REDIR_OUT, - VAL_REDIR_APPEND, - VAL_CMD, - VAL_SEXPR, -} t_val_type; + int status; + int in_pipe[2]; // need stack pipe + int out_pipe[2]; + t_path path; + t_env env; +} t_eval_state; /** -** \brief An evaluation node struct -** \param type type of node -** \param data union of possible data -** \param data::fd file descriptor for redirection node -** \param data::str string for error, arguments, command +** \brief Evaluation status struct */ typedef struct { - t_val_type type; - union - { - char *str; - int code; - int fd; - } data; -} t_val; + char *err; + int status; +} t_eval_status; + /** -** \brief evaluate an AST -** \param path path to commands executable -** \param env environment variables -** \param ast Abstract syntax tree to evaluate +** \brief Evaluate an AST +** \param state State of the evaluation +** \param ast Abstract syntax tree to evaluate */ -int ms_eval(t_path path, t_env env, t_ast *ast); + +int ms_eval(t_eval_state *state, t_ast *ast); #endif |
