From 0ee30bdc0e6cb7ade2cb9a54165f8de6eea3721c Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 24 Mar 2020 18:27:55 +0100 Subject: Added comments to the ms_parse.h structs --- .gitignore | 1 + include/ms_parse.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/.gitignore b/.gitignore index b24309c..8461336 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ minishell *.o *.ghc *.a +tags diff --git a/include/ms_parse.h b/include/ms_parse.h index 4a6ebfa..c6885ca 100644 --- a/include/ms_parse.h +++ b/include/ms_parse.h @@ -15,6 +15,18 @@ # include "minishell.h" +/* +** TAG_CMD: command name +** TAG_ARG: command argument +** TAG_ENDCMD: `;` +** TAG_PIPE: `|` +** TAG_AND: `&&` +** TAG_OR: `||` +** TAG_REDIR_OUT: `>` +** TAG_REDIR_IN: `<` +** TAG_REDIR_APPEND: `>>` +*/ + typedef enum { TAG_CMD, @@ -28,6 +40,31 @@ typedef enum TAG_REDIR_APPEND } t_tag; +/* +** AST (Abstract Syntax Tree) +** A node of the ast is represented by a tag (his type) and a content associated with it. +** (i.e a TAG_CMD would be paired with the command executable name) +** Each node also has children node which must be evaluated before him +** +** examle: "echo foo bar && ls" +** +** tags: +** TAG_AND +** / \ +** / \ +** TAG_CMD TAG_CMD +** / \ +** TAG_ARG TAG_ARG +** +** content: +** && +** / \ +** / \ +** echo ls +** / \ +** foo bar +*/ + typedef struct t_ast { t_tag tag; char* contents; -- cgit