From 9cb6535a17cf741a4a60bca597155d3a3ba6a44d Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Thu, 27 Oct 2005 00:00:36 +0000 Subject: [PATCH] Fixed assertion in first The implementation assumed there would be no rules starting with terminals since they were eliminated at the first chance. However, rules starting with a non-terminal which produced the empty string followed by a terminal were added to the set of rules. git-archimport-id: cascardo@tlscascardo--private/libgrammatic--nogobject-lr1--0.1--patch-10 --- first.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/first.c b/first.c index 040a04c..0b25ecb 100644 --- a/first.c +++ b/first.c @@ -372,12 +372,10 @@ void first_iterate (gpointer key, gpointer val, gpointer data) first_set->has_empty = TRUE; rule_delete (next_rule); } - else + else if (next_symbol->terminal == FALSE) { symbol_t* next_symbol; next_symbol = next_symbols->data; - /* TODO: Check this assertion is correct. */ - assert (next_symbol->terminal == FALSE); /* This is an indirect recursive rule. */ if (next_symbol->value == symbol->value) { @@ -392,6 +390,10 @@ void first_iterate (gpointer key, gpointer val, gpointer data) new_rules = g_list_prepend (new_rules, next_rule); } } + else + { + rule_delete (next_rule); + } next_rules = g_list_next (next_rules); } } -- 2.20.1