MiniDevil As beautiful as a shell
token.c File Reference

Token allocation and management: creates & frees token nodes. More...

#include "token.h"
#include "libft.h"
+ Include dependency graph for token.c:

Detailed Description

Token allocation and management: creates & frees token nodes.

Definition in file token.c.

Functions

t_tokencreate_token (t_token_type type, char *value)
 Allocate and initialize a new token. More...
 
void free_token (t_token *token)
 Free a single token and its value str. More...
 
void free_token_list (t_token *head)
 Free the entire token linked list. More...
 
void add_token (t_token **head, t_token *new_token)
 Add a token to the end of a linked list. More...
 

Function Documentation

◆ create_token()

t_token* create_token ( t_token_type  type,
char *  value 
)

Allocate and initialize a new token.

The new token starts with quote_type = QUOTE_NONE, connected = 0 and next = NULL

Parameters
typeToken type
valueText content
Returns
Newly allocated token or NULL on failure

Definition at line 26 of file token.c.

References t_token::connected, t_token::next, QUOTE_NONE, t_token::quote_type, t_token::type, and t_token::value.

Referenced by process_operator_token(), and process_word_token().

+ Here is the caller graph for this function:

◆ free_token()

void free_token ( t_token token)

Free a single token and its value str.

Parameters
tokenToken to free

Definition at line 51 of file token.c.

References t_token::value.

Referenced by free_token_list().

+ Here is the caller graph for this function:

◆ free_token_list()

void free_token_list ( t_token head)

Free the entire token linked list.

Parameters
headHead of list to free

Definition at line 64 of file token.c.

References free_token(), and t_token::next.

Referenced by process_input(), process_ui_input(), and tokenize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_token()

void add_token ( t_token **  head,
t_token new_token 
)

Add a token to the end of a linked list.

Parameters
headPointer to head pointer
new_tokenToken to add

Definition at line 84 of file token.c.

References t_token::next.

Referenced by process_operator_token(), and process_word_token().

+ Here is the caller graph for this function:

Go to the source code of this file.