From 8103cadfc95fb76539bfccc893a2101ccb89ea90 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Fri, 28 Jun 2024 15:09:32 +0200 Subject: 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--- src/new_token.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/new_token.c (limited to 'src/new_token.c') diff --git a/src/new_token.c b/src/new_token.c new file mode 100644 index 0000000..92ff421 --- /dev/null +++ b/src/new_token.c @@ -0,0 +1,52 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* new_token.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dkaiser type = type; + token->previous = previous; + token->next = next; + if (previous != NULL) + token->previous->next = token; + if (next != NULL) + token->next->previous = token; + return (token); +} + +t_token *new_str_token(char *str, t_token *previous, t_token *next) +{ + t_token *token; + + token = new_token(STRING_TOKEN, previous, next); + if (token == NULL) + return (NULL); + token->content.string = str; + return (token); +} + +t_token *new_redir_token(int type, t_token *previous, t_token *next) +{ + t_token *token; + + token = new_token(REDIR_TOKEN, previous, next); + if (token == NULL) + return (NULL); + token->content.redir_type = type; + return (token); +} -- cgit v1.2.3