minishell
Minishell Project for École 42
|
Functions for tokenizing the input string and creating a lexer list. More...
#include "minishell.h"
Functions | |
t_token | assign_type (char tok) |
Assign a type based on the input char. | |
t_token | which_type (char *s) |
Set the type of token. | |
t_lexer_list * | create_lexer_list (char **input_array) |
Allocates memory for the lexer list. | |
t_lexer_list * | fill_lexer_list (char **input_array) |
Fills the lexer list using the input array. | |
t_lexer_list * | tokenize (t_shell *shell) |
Tokenizes the input string and creates the lexer list. | |
Functions for tokenizing the input string and creating a lexer list.
t_token assign_type | ( | char | tok | ) |
Assign a type based on the input char.
tok | The input char to assign a tyoe for. |
t_lexer_list * create_lexer_list | ( | char ** | input_array | ) |
Allocates memory for the lexer list.
Creates a double-linked list using the size of the input array. Calculates size of input array. and allocates memory for the lexer list. If malloc fails, displays error message, returns NULL.
input_array | The array with the substrings('tokens'). |
t_lexer_list * fill_lexer_list | ( | char ** | input_array | ) |
Fills the lexer list using the input array.
Calls create_lexer_list() to allocates a double-linked list with as many nodes as substrings in input_array. Fills each node of the list with information about each 'token'.
input_array | The array with the substrings('tokens'). |
t_lexer_list * tokenize | ( | t_shell * | shell | ) |
Tokenizes the input string and creates the lexer list.
Tokenizes the input by creating an array of substrings. Creates a linked list of lexer tokens using the substrings. Returns a pointer to the head of the lexer linked list. if malloc fails for input_array or lexer list, display message and return NULL.
shell | The shell data structure (main data structure). @ return The head of the lexer list if successful, otherwise NULL. |
t_token which_type | ( | char * | s | ) |
Set the type of token.
Takes an input string('token') and chooses the type of token it represents. Only sets if the token is a pipe or some redirection, otherwise sets type to NONE.
s | The input string ('token') to identify the type for. |