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/ast.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/ast.h')
| -rw-r--r-- | include/ast.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/include/ast.h b/include/ast.h new file mode 100644 index 0000000..4ee3396 --- /dev/null +++ b/include/ast.h @@ -0,0 +1,80 @@ +#ifndef AST_H +# define AST_H + +/** +** \file ast.h +** \brief AST structs +*/ + +/** +** \brief Separator type +** \param SEP_END Regular command end `;` +** \param SEP_PIPE Pipe output of left to right `|` +** \param SEP_AND Execute right if left status == 0 `&&` +** \param SEP_OR Execute right if left status != 0 `||` +*/ + +typedef enum +{ + SEP_END, + SEP_PIPE, + SEP_AND, + SEP_OR, +} t_sep; + +typedef struct s_ast t_ast; +/** +** \brief Line struct +** \param left AST to the left of separator +** \param right AST to the right of separator +** \param sep Type of separator +*/ + +typedef struct +{ + t_ast *left; + t_ast *right; + t_sep sep; +} t_line; + +/** +** \brief Command struct +** \param argv Array of string, all arguments beginning with executable name +** \param in STDIN redirection filename +** \param out STDOUT redirection filename +** \param is_append True if out redirection is append to file +*/ + +typedef struct +{ + char **argv; + char *in; + char *out; + bool is_append; +} t_cmd; + +typedef enum +{ + TAG_CMD, + TAG_LINE, +} t_ast_tag; + +/** +** \brief AST node struct +** \param type Node type +** \param data Union containning possible node data +** \param data::cmd Command struct +** \param data::line Line struct +*/ + +struct s_ast +{ + t_ast_tag tag; + union + { + t_line line; + t_cmd cmd; + } data; +}; + +#endif |
