private PrologCodeTerm ConvertBinaryListToCodeDOM(BinaryTree l)
{
BinaryList list = (BinaryList)l;
if (list.Head == null && list.Tail == null)
{
return new PrologCodeEmptyList();
}
PrologCodeNonEmptyList NEList = null;
if (list.Head.Name == ".")
{
NEList = new PrologCodeNonEmptyList(ConvertBinaryListToCodeDOM(list.Head));
}
else
{
NEList = new PrologCodeNonEmptyList(ConvertGoalVariableBinaryTreeToCodeDOM(list.Head));
}
// Check the tail
if (list.Tail.Name == ".")
{
NEList.Tail = ConvertBinaryListToCodeDOM(list.Tail);
}
else
{
NEList.Tail = ConvertGoalVariableBinaryTreeToCodeDOM(list.Tail);
}
return NEList;
}