🏗️」 wip: __to_token nearly done

This commit is contained in:
2024-05-23 20:53:07 +02:00
parent ce0ef1d897
commit 6a8a6382bd
12 changed files with 305 additions and 60 deletions

19
include/error_msg.h Normal file
View File

@ -0,0 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error_msg.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/20 20:25:06 by adjoly #+# #+# */
/* Updated: 2024/05/20 21:00:45 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef ERROR_MSG_H
# define ERROR_MSG_H
/**
* Here we define all the error message
*/
#endif

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/25 12:20:26 by adjoly #+# #+# */
/* Updated: 2024/05/19 13:45:01 by adjoly ### ########.fr */
/* Updated: 2024/05/23 19:56:20 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -24,18 +24,52 @@ typedef struct s_cmd
int outfile;
} t_cmd;
typedef enum s_quote
{
NOT_CLOSED = -1,
FALSE,
SINGLE,
DOUBLE
} t_quote;
/**
* @brief Take the argv of a command a split the argv and the command it self
* @brief Take the argv of a command a split the argv and the
* command it self
*
* @param The full argv of the command
* @param cmd_av The full argv of the command
*
* @return (t_cmd *) cmd and argv splited into a struct
*/
t_cmd *split_cmd(char *cmd_av);
/*
* @deprecated
/**
* @brief Take a string and an index and check if the character
* at the index is in quote
*
* @param s The string to search in
* @param i The index of the character to check
*
* @return (t_quote) The type of quote if between, if not return FALSE or
* NOT_CLOSED if the quote is not closed
*/
t_list *split_pipe(char *readline);
t_quote is_inquote(char *s, size_t i);
/**
* @brief Take a character and check if it is a quote and return the
* type of quote
*
* @param c The character to check
*
* @return (t_quote) The type of quote or FALSE
*/
t_quote __is_quote(char c);
/*
* ONLY FOR DEBUG TO BE REMOVED
*/
void print_quote_type(t_quote type);
void print_redir_sign(t_redirection_sign redir_sign);
void print_token(t_token *token);
void print_redir(t_redirection *redir);
#endif

View File

@ -6,20 +6,19 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/18 20:14:15 by adjoly #+# #+# */
/* Updated: 2024/05/19 14:02:58 by adjoly ### ########.fr */
/* Updated: 2024/05/23 12:11:42 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef TOKENIZER_H
#ifndef TOKENIZER_H
# define TOKENIZER_H
# include "libft.h"
# include <stdbool.h>
typedef enum s_redirection_sign
typedef enum s_redirection_sign
{
HEREDOC,
INFILE,
HEREDOC,
OUTFILE,
OUT_APPEND,
} t_redirection_sign;
@ -37,7 +36,8 @@ typedef struct s_token
} t_token;
/**
* @brief Convert the raw command into a t_token that contains the argv of the command an a linked list of redirection
* @brief Convert the raw command into a t_token that contains
* the argv of the command an a linked list of redirection
*
* @param cmd A string that containt the command to tokenize
*
@ -47,16 +47,18 @@ typedef struct s_token
t_token *__to_token(char *cmd);
/**
* @brief **
* @brief
*
* @param
* @param The readline output
*
* @return ()
* @return (t_list *) A linked lst of all the command splited
*
*/
t_list *__split_pipe(char *readline);
/**
* @brief Convert the readline output, split all command and put it in linked list of t_token (given by t_token function)
* @brief Convert the readline output, split all command and put
* it in linked list of t_token (given by t_token function)
*
* @param readline The readline output
*