/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/21 15:34:14 by ljiriste #+# #+# */
-/* Updated: 2024/07/04 12:22:27 by ljiriste ### ########.fr */
+/* Updated: 2024/07/11 21:33:32 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
+static const t_token empty_token = {.type = "''", .str = NULL};
+
int push_state(t_stack *stack, size_t state_num, t_token token)
{
t_parser_stack_element element;
{
t_parse_tree_node *node;
- node = ((t_parser_stack_element *)ft_stack_pop(stack, NULL))->node;
+ if (!ft_strcmp(constituent_token->type, "''"))
+ {
+ node = malloc(sizeof(*node));
+ if (!node || ft_vec_init(&node->children, sizeof(*node)))
+ {
+ free(node);
+ return (1);
+ }
+ node->token = ft_token_dup(&empty_token);
+ }
+ else
+ node = ((t_parser_stack_element *)ft_stack_pop(stack, NULL))->node;
if (ft_strcmp(node->token.type, constituent_token->type)
|| ft_vec_insert(&tree->children, node, 0) != success)
{