public void run(final Node startNode, final PipeOut forwardPipe)
{
AutoReducingQueue arQueue;
Node n = startNode;
PipeOut lastPipe = null;
do
{
if (n instanceof LogicalStatement)
{
arQueue = new AutoReducingQueue(((LogicalStatement) n).getNest(), this);
}
else if (n instanceof PipeNode)
{
if (lastPipe == null)
{
throw new RuntimeException("broken pipe");
}
run(((PipeNode) n).getNest(), lastPipe);
continue;
}
else
{
throw new RuntimeException("badly formed stack:" + n);
}
Queue<String> outQueue = new LinkedList<String>();
for (String s : arQueue)
{
if (s == null || s.equals(""))
{
continue;
}
outQueue.add(s);
}
if (!outQueue.isEmpty())
{
PipeOut pipeOut = new PipeOutImpl(shell);
if (n.next != null && n.next instanceof PipeNode)
{
pipeOut.setPiped(true);
lastPipe = pipeOut;
}
Node x = n;
while (x instanceof LogicalStatement && (x = ((LogicalStatement) x).nest) != null)