aboutsummaryrefslogtreecommitdiff
path: root/include/ms_parse.h
diff options
context:
space:
mode:
authornass1pro <nass1pro@gmail.com>2020-03-24 18:31:59 +0100
committernass1pro <nass1pro@gmail.com>2020-03-24 18:31:59 +0100
commit6b6cec716aa2baac0065e8fa0e52b89e1e0c4f1e (patch)
tree4a5e06e08866738fb127bce125f34030ffeb9627 /include/ms_parse.h
parent19a305ae711f9d552e98f74db7f1c264fe99dbb2 (diff)
parent0ee30bdc0e6cb7ade2cb9a54165f8de6eea3721c (diff)
downloadminishell-6b6cec716aa2baac0065e8fa0e52b89e1e0c4f1e.tar.gz
minishell-6b6cec716aa2baac0065e8fa0e52b89e1e0c4f1e.tar.bz2
minishell-6b6cec716aa2baac0065e8fa0e52b89e1e0c4f1e.zip
parser_lexer
Diffstat (limited to 'include/ms_parse.h')
-rw-r--r--include/ms_parse.h37
1 files changed, 37 insertions, 0 deletions
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;