Implementation of the shunting-yard algorithm (http://en.wikipedia.org/wiki/Shunting-yard_algorithm)