private void WalkGoal(KnowledgeBase kb, KnowledgeBaseRule rule, object goal)
{
goal = Term.Deref(goal);
var atom = goal as Symbol;
if (atom != null)
{
var p = new PredicateIndicator(atom, 0);
if (PrologPrimitives.IsDefined(p))
{
return;
}
var predicate = kb.CheckForPredicateInfo(p);
if (predicate == null)
{
rule.PrintWarning("undefined predicate {0}", p);
}
else
{
MarkReferenced(predicate);
}
}
else
{
var s = goal as Structure;
if (s != null)
{
WalkGoal(kb, rule, s);
}
else if (!(goal is LogicVariable) && !(goal is bool))
{
rule.PrintWarning("malformed goal: {0}", goal);
}
}
}