From: Thadeu Lima de Souza Cascardo Date: Thu, 27 Oct 2005 00:00:36 +0000 (+0000) Subject: Fixed assertion in first X-Git-Tag: cascardo@tlscascardo--private,libgrammatic--regular--0.1--base-0~2 X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fgrammar.git;a=commitdiff_plain;h=9cb6535a17cf741a4a60bca597155d3a3ba6a44d 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 --- 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); } }