Java implementation of Dijkstra's shunting yard algorithm