From aa906f5400c41bc101734eea0e7cbce0f64b2273 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Thu, 27 Oct 2005 00:28:14 +0000 Subject: [PATCH] Fixed first Previous fix in first was not correct because it used a variable not yet declared. This version checks for the rule starting with a terminal instead of ignoring them. git-archimport-id: cascardo@tlscascardo--private/libgrammatic--nogobject-lr1--0.1--patch-11 --- first.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/first.c b/first.c index 0b25ecb..da7d344 100644 --- a/first.c +++ b/first.c @@ -372,12 +372,20 @@ void first_iterate (gpointer key, gpointer val, gpointer data) first_set->has_empty = TRUE; rule_delete (next_rule); } - else if (next_symbol->terminal == FALSE) + else { symbol_t* next_symbol; next_symbol = next_symbols->data; + /* + * This rule starts with a terminal. Ignore it. + * We could add it as an optimization. TODO + */ + if (next_symbol->terminal) + { + rule_delete (next_rule); + } /* This is an indirect recursive rule. */ - if (next_symbol->value == symbol->value) + else if (next_symbol->value == symbol->value) { first_set->recursive = g_list_prepend (first_set->recursive, @@ -390,10 +398,6 @@ 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