From 61493998e35bd6adf5a02876cff6095a6e69e6c9 Mon Sep 17 00:00:00 2001 From: Charles Date: Sun, 8 Mar 2020 14:42:54 +0100 Subject: Changing the parsing struct to an AST --- include/ms_parse.h | 48 +++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/include/ms_parse.h b/include/ms_parse.h index 59c9ca8..4a6ebfa 100644 --- a/include/ms_parse.h +++ b/include/ms_parse.h @@ -17,37 +17,23 @@ typedef enum { - REDIRECTION_OUT, - REDIRECTION_IN, - REDIRECTION_APPEND -} t_redirection_type; - -typedef struct -{ - char *filename; - t_redirection_type type; -} t_redirection; - -typedef struct -{ - char *name; - char **argv; - t_ftlst *redirections; // need to store them in reverse order -} t_command; - -typedef enum -{ - SEPARATOR_SEMICOLON, - SEPARATOR_PIPE, - // SEPARATOR_AND, // with parhenthesis => harder - // SEPARATOR_OR, -} t_separator; - -typedef struct -{ - t_ftlst *commands; - t_ftlst *separators; -} t_parsing; + TAG_CMD, + TAG_ARG, + TAG_ENDCMD, + TAG_PIPE, + TAG_AND, + TAG_OR, + TAG_REDIR_OUT, + TAG_REDIR_IN, + TAG_REDIR_APPEND +} t_tag; + +typedef struct t_ast { + t_tag tag; + char* contents; + int children_num; + struct t_ast** children; +} t_ast; /* ** parse.c -- cgit