From 284f68af27b6c47c29282b475cb5d1d87044fe1d Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Thu, 4 Jul 2024 14:45:37 +0200 Subject: [PATCH] Change the code to accommodate the zeroth rule --- ft_parse/ft_parsing_table_generate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ft_parse/ft_parsing_table_generate.c b/ft_parse/ft_parsing_table_generate.c index 236a0ef..e61b67e 100644 --- a/ft_parse/ft_parsing_table_generate.c +++ b/ft_parse/ft_parsing_table_generate.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/27 11:16:53 by ljiriste #+# #+# */ -/* Updated: 2024/07/04 14:25:35 by ljiriste ### ########.fr */ +/* Updated: 2024/07/04 14:36:08 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -203,7 +203,7 @@ size_t find_kernel(const t_vec *kernel, const t_vec *states) const t_token *get_next_token(const t_marked_grammar_rule *rule) { - return (ft_vec_caccess(&rule->rule->constituents, rule->position + 1)); + return (ft_vec_caccess(&rule->rule->constituents, rule->position)); } int is_terminal_token(const t_token *token, const t_vec *tokens) @@ -240,7 +240,7 @@ t_ft_stat add_first(t_vec *lookahead, const t_token *token, const t_vec *rules, return (res); } rule.position = 0; - i = 0; + i = 1; while (i < rules->size) { rule.rule = ft_vec_caccess(rules, i); @@ -312,7 +312,7 @@ t_ft_stat add_predictions(t_vec *closure, const t_lr1_item *item, const t_vec *r t_lr1_item new_item; t_ft_stat res; - i = 0; + i = 1; while (i < rules->size) { new_item.core.rule = ft_vec_caccess(rules, i); @@ -521,7 +521,7 @@ t_ft_stat add_constituents(t_vec *tokens, const t_vec *constituents, const t_vec while (i < constituents->size) { token = ft_vec_caccess(constituents, i); - if (ft_vec_contains(tokens, token, void_cmp_token_type)) + if (ft_vec_contains(tokens, token, void_cmp_token_type) || !cmp_token_type(token, &empty_token)) { ++i; continue ; -- 2.30.2