update: made some changes
This commit is contained in:
parent
32afaabbbc
commit
3ee9c00d5a
6 changed files with 100 additions and 25 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/27 22:18:46 by rparodi #+# #+# */
|
||||
/* Updated: 2024/09/28 11:47:09 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/09/28 14:50:56 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,6 +16,12 @@
|
|||
#include "me/types.h"
|
||||
#include <stdio.h>
|
||||
|
||||
// MAIX: C'est necessaire de split ca dans une fonction a par vu que ca retourne
|
||||
// la valeur de la comparaion ?
|
||||
// Ca serai pas mieux de faire une fonction du genre
|
||||
// "bool create_single_char_token(char c, t_token *tok)" qui cree un token
|
||||
// dans `tok` et retourne true si il a match un char qui correspond
|
||||
// a un token specific (genre $ ou parentheses par example)
|
||||
/**
|
||||
* @brief boolean function that's say if it's a dollar or not
|
||||
*
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/25 16:27:03 by rparodi #+# #+# */
|
||||
/* Updated: 2024/09/28 12:16:45 by rparodi ### ########.fr */
|
||||
/* Updated: 2024/09/28 14:48:31 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -18,6 +18,9 @@
|
|||
#include <stdbool.h>
|
||||
#include "me/mem/mem.h"
|
||||
|
||||
|
||||
// MAIX: attention les whitespace peuvent aussi etre des tab. de memoire il y a
|
||||
// une fonction "me_isspace" qui check ce qu'on veut dans "me/char/char.h"
|
||||
/**
|
||||
* @brief boolean function that's say if it's a space or not
|
||||
*
|
||||
|
|
@ -31,22 +34,27 @@ bool is_space(char c)
|
|||
return (false);
|
||||
}
|
||||
|
||||
// MAIX: tu peux faire un token par character "whitespace", vu qu'on va
|
||||
// manipuler la list de token apres pour faire des truc plus simple a process
|
||||
// on se debrouillera pour plus avoir plein de token whitespace :)
|
||||
t_error start_analyse(t_const_str raw, enum e_token list, t_vec_token *output)
|
||||
{
|
||||
t_usize i;
|
||||
t_token token;
|
||||
|
||||
i = 0;
|
||||
mem_alloc(sizeof(t_token));
|
||||
while (raw[i] != '\0')
|
||||
{
|
||||
if (is_space(raw[i]))
|
||||
token =
|
||||
token = token_new(WHITESPACE);
|
||||
i++;
|
||||
}
|
||||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
// MAIX: attention tu ne fais rien avec le vec_token ici :D
|
||||
// aussi l'argument list est censer faire quoi ?
|
||||
// c'est un reste d'une version ancienne ?
|
||||
t_error tokeniser(t_const_str raw, enum e_token list)
|
||||
{
|
||||
t_vec_token output;
|
||||
|
|
|
|||
41
parser/src/token_lifetime.c
Normal file
41
parser/src/token_lifetime.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* token_lifetime.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/28 14:37:13 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/28 14:57:17 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/vec/vec_token.h"
|
||||
#include "parser/token.h"
|
||||
|
||||
void token_free(t_token tok)
|
||||
{
|
||||
if (tok.string.buf != NULL)
|
||||
string_free(tok.string);
|
||||
if (tok.subtokens.buffer != NULL)
|
||||
vec_token_free(tok.subtokens);
|
||||
}
|
||||
|
||||
t_token token_new(enum e_token type)
|
||||
{
|
||||
return ((t_token){.type = type, .string = string_new(16), \
|
||||
.subtokens = {NULL, 0, 0, NULL}});
|
||||
}
|
||||
|
||||
t_token token_new_meta(enum e_token type)
|
||||
{
|
||||
return ((t_token){.type = type, .string = {NULL, 0, 0}, \
|
||||
.subtokens = vec_token_new(16, token_free)});
|
||||
}
|
||||
|
||||
bool token_is_meta(t_token tok)
|
||||
{
|
||||
if (tok.type == WORD)
|
||||
return (true);
|
||||
return (false);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue