/* By: ljiriste <ljiriste@student.42prague.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/27 11:16:53 by ljiriste #+# #+# */
-/* Updated: 2024/07/04 13:24:49 by ljiriste ### ########.fr */
+/* Updated: 2024/07/04 14:25:35 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
return (solve_gotos(state, states, rules, tokens));
}
-int is_at_mark(__attribute__((unused))const t_token *token, __attribute__((unused))const t_generator_state *state)
+int is_at_mark(const t_token *token, const t_generator_state *state)
{
- ft_printf("is_at_mark is not yet implemented\n");
- return (1);
+ size_t i;
+ const t_lr1_item *item;
+
+ i = 0;
+ while (i < state->kernel.size)
+ {
+ item = ft_vec_caccess(&state->kernel, i);
+ if (!cmp_token_type(token, ft_vec_caccess(&item->core.rule->constituents, item->core.position)))
+ return (1);
+ ++i;
+ }
+ while (i < state->closure.size)
+ {
+ item = ft_vec_caccess(&state->closure, i);
+ if (!cmp_token_type(token, ft_vec_caccess(&item->core.rule->constituents, item->core.position)))
+ return (1);
+ ++i;
+ }
+ return (0);
}
t_ft_stat solve_gotos(t_generator_state *state, t_vec *states, const t_vec *rules, const t_vec *tokens)