aboutsummaryrefslogtreecommitdiff
path: root/include/token.h
diff options
context:
space:
mode:
authorDominik Kaiser2024-06-28 15:09:32 +0200
committerGitHub2024-06-28 15:09:32 +0200
commit8103cadfc95fb76539bfccc893a2101ccb89ea90 (patch)
treeb46379099324f76f2496909b4de3cd71de8b772a /include/token.h
parent031685832d8267acc2fa46ea9732b8e95eb34463 (diff)
downloadminishell-8103cadfc95fb76539bfccc893a2101ccb89ea90.tar.gz
minishell-8103cadfc95fb76539bfccc893a2101ccb89ea90.zip
Add data structures for tokenizing and parsing
* Add data structures and helper functions for ast * Add data structures for tokenizing * Add helper functions for token structures * Include token.h in minishell.h * Add new/free functions for nodes/tokens to Makefile * Add UNREACHABLE macro to debug_tools.h
Diffstat (limited to 'include/token.h')
-rw-r--r--include/token.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/include/token.h b/include/token.h
new file mode 100644
index 0000000..38e758f
--- /dev/null
+++ b/include/token.h
@@ -0,0 +1,49 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* token.h :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2024/06/27 13:27:18 by dkaiser #+# #+# */
+/* Updated: 2024/06/28 14:59:19 by dkaiser ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef TOKEN_H
+# define TOKEN_H
+
+# include "stdlib.h"
+
+enum e_token_type
+{
+ STRING_TOKEN,
+ PIPE_TOKEN,
+ REDIR_TOKEN,
+ NEWLINE_TOKEN
+};
+
+union u_token_content
+{
+ char *string;
+ int redir_type;
+};
+
+typedef struct s_token
+{
+ int type;
+ union u_token_content content;
+ struct s_token *previous;
+ struct s_token *next;
+} t_token;
+
+t_token *new_token(int type, t_token *previous,
+ t_token *next);
+t_token *new_str_token(char *str, t_token *previous,
+ t_token *next);
+t_token *new_redir_token(int type, t_token *previous,
+ t_token *next);
+
+void free_token(t_token *token);
+
+#endif