I recently discovered that scala.collection.mutable.Stack is implemented in terms of a scala.collection.immutable.List.
So every push allocates, every pop discards a list cell.
We push and pop a bunch of stacks for every move the parser and unparser make.
In addition the length() method takes O time for n items on the stack, though I'm not sure we ever call this.
We should build a mutable stack class that uses an ArrayBuffer for the implementation.
This will likely be faster, and will not push hard on the garbage collector.