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_set->has_empty = TRUE;
rule_delete (next_rule);
}
first_set->has_empty = TRUE;
rule_delete (next_rule);
}
- else if (next_symbol->terminal == FALSE)
{
symbol_t* next_symbol;
next_symbol = next_symbols->data;
{
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. */
/* 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,
{
first_set->recursive =
g_list_prepend (first_set->recursive,
new_rules = g_list_prepend (new_rules, next_rule);
}
}
new_rules = g_list_prepend (new_rules, next_rule);
}
}
- else
- {
- rule_delete (next_rule);
- }
next_rules = g_list_next (next_rules);
}
}
next_rules = g_list_next (next_rules);
}
}