The venerable shunting yard algorithm by Dijkstra