split heredoc handling in the scanner

This commit is contained in:
Maieul BOYER 2024-09-01 19:56:22 +00:00
parent 8be7417a61
commit 7e1e51e90b
30 changed files with 663 additions and 416 deletions

View file

@ -120,4 +120,14 @@ void vec_ast_sort(t_vec_ast *vec, t_vec_ast_sort_fn is_sorted);
/// @return true if the operation failed, false otherwise
t_error vec_ast_back(t_vec_ast *vec, t_ast_node **out);
/// @brief Get a pointer to the i'th element, or NULL otherwise
/// @param vec The vec_ast to get the element from
/// @return A pointer to the element or NULL
t_ast_node *vec_ast_get(t_vec_ast *vec, t_usize i);
/// @brief Get a pointer to the last element, or NULL otherwise
/// @param vec The vec_ast to get the element from
/// @return A pointer to the last element or NULL
t_ast_node *vec_ast_last(t_vec_ast *vec);
#endif

View file

@ -120,4 +120,14 @@ void vec_estr_sort(t_vec_estr *vec, t_vec_estr_sort_fn is_sorted);
/// @return true if the operation failed, false otherwise
t_error vec_estr_back(t_vec_estr *vec, t_expandable_str **out);
/// @brief Get a pointer to the i'th element, or NULL otherwise
/// @param vec The vec_estr to get the element from
/// @return A pointer to the element or NULL
t_expandable_str *vec_estr_get(t_vec_estr *vec, t_usize i);
/// @brief Get a pointer to the last element, or NULL otherwise
/// @param vec The vec_estr to get the element from
/// @return A pointer to the last element or NULL
t_expandable_str *vec_estr_last(t_vec_estr *vec);
#endif

View file

@ -120,4 +120,14 @@ void vec_heredoc_sort(t_vec_heredoc *vec, t_vec_heredoc_sort_fn is_sorted);
/// @return true if the operation failed, false otherwise
t_error vec_heredoc_back(t_vec_heredoc *vec, t_heredoc **out);
/// @brief Get a pointer to the i'th element, or NULL otherwise
/// @param vec The vec_heredoc to get the element from
/// @return A pointer to the element or NULL
t_heredoc *vec_heredoc_get(t_vec_heredoc *vec, t_usize i);
/// @brief Get a pointer to the last element, or NULL otherwise
/// @param vec The vec_heredoc to get the element from
/// @return A pointer to the last element or NULL
t_heredoc *vec_heredoc_last(t_vec_heredoc *vec);
#endif

View file

@ -120,4 +120,14 @@ void vec_pid_sort(t_vec_pid *vec, t_vec_pid_sort_fn is_sorted);
/// @return true if the operation failed, false otherwise
t_error vec_pid_back(t_vec_pid *vec, t_pid **out);
/// @brief Get a pointer to the i'th element, or NULL otherwise
/// @param vec The vec_pid to get the element from
/// @return A pointer to the element or NULL
t_pid *vec_pid_get(t_vec_pid *vec, t_usize i);
/// @brief Get a pointer to the last element, or NULL otherwise
/// @param vec The vec_pid to get the element from
/// @return A pointer to the last element or NULL
t_pid *vec_pid_last(t_vec_pid *vec);
#endif

View file

@ -120,4 +120,14 @@ void vec_str_sort(t_vec_str *vec, t_vec_str_sort_fn is_sorted);
/// @return true if the operation failed, false otherwise
t_error vec_str_back(t_vec_str *vec, t_str **out);
/// @brief Get a pointer to the i'th element, or NULL otherwise
/// @param vec The vec_str to get the element from
/// @return A pointer to the element or NULL
t_str *vec_str_get(t_vec_str *vec, t_usize i);
/// @brief Get a pointer to the last element, or NULL otherwise
/// @param vec The vec_str to get the element from
/// @return A pointer to the last element or NULL
t_str *vec_str_last(t_vec_str *vec);
#endif

View file

@ -10,8 +10,6 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/vec/vec_ast.h"

View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_ast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */
/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/vec/vec_ast.h"
#include <stdlib.h>
t_ast_node *vec_ast_get(t_vec_ast *vec, t_usize i)
{
if (vec->len >= i)
return (NULL);
return (&vec->buffer[i]);
}
t_ast_node *vec_ast_last(t_vec_ast *vec)
{
if (vec->len == 0)
return (NULL);
return (&vec->buffer[vec->len - 1]);
}

View file

@ -10,8 +10,6 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/vec/vec_estr.h"

View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_estr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */
/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/vec/vec_estr.h"
#include <stdlib.h>
t_expandable_str *vec_estr_get(t_vec_estr *vec, t_usize i)
{
if (vec->len >= i)
return (NULL);
return (&vec->buffer[i]);
}
t_expandable_str *vec_estr_last(t_vec_estr *vec)
{
if (vec->len == 0)
return (NULL);
return (&vec->buffer[vec->len - 1]);
}

View file

@ -10,8 +10,6 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/vec/vec_heredoc.h"

View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_heredoc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */
/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/vec/vec_heredoc.h"
#include <stdlib.h>
t_heredoc *vec_heredoc_get(t_vec_heredoc *vec, t_usize i)
{
if (vec->len >= i)
return (NULL);
return (&vec->buffer[i]);
}
t_heredoc *vec_heredoc_last(t_vec_heredoc *vec)
{
if (vec->len == 0)
return (NULL);
return (&vec->buffer[vec->len - 1]);
}

View file

@ -10,8 +10,6 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/vec/vec_pid.h"

View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_pid.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */
/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/vec/vec_pid.h"
#include <stdlib.h>
t_pid *vec_pid_get(t_vec_pid *vec, t_usize i)
{
if (vec->len >= i)
return (NULL);
return (&vec->buffer[i]);
}
t_pid *vec_pid_last(t_vec_pid *vec)
{
if (vec->len == 0)
return (NULL);
return (&vec->buffer[vec->len - 1]);
}

View file

@ -10,8 +10,6 @@
/* */
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/vec/vec_str.h"

View file

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_str.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */
/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/vec/vec_str.h"
#include <stdlib.h>
t_str *vec_str_get(t_vec_str *vec, t_usize i)
{
if (vec->len >= i)
return (NULL);
return (&vec->buffer[i]);
}
t_str *vec_str_last(t_vec_str *vec)
{
if (vec->len == 0)
return (NULL);
return (&vec->buffer[vec->len - 1]);
}