private LNode GenerateRandomNode(LNodeFactory Factory, Random Rand, int Depth)
{
int index = Rand.Next(5);
switch (Depth <= 0 && index > 1 ? Rand.Next(2) : index)
{
case 0:
return Factory.Literal(GenerateRandomLiteral(Rand));
case 1:
return Factory.Id(GenerateRandomSymbol(Rand));
case 2:
return Factory.Attr(GenerateRandomNode(Factory, Rand, Depth - 1), GenerateRandomNode(Factory, Rand, Depth - 1));
case 3:
return Factory.Call(GenerateRandomSymbol(Rand), GenerateRandomNodeList(Factory, Rand, Depth - 1));
default:
return Factory.Call(GenerateRandomNode(Factory, Rand, Depth - 1), GenerateRandomNodeList(Factory, Rand, Depth - 1));
}
}