Was reading the SWI-Prolog commit C18r145 and noticed
complex_term() handles operator resolution. This is based on an old book
on compiler design of which I’ve forgotten the name. The idea is to have
two queues, the side queue and the out queue. The number of elements
pushed there is inside_n
andout_n
. As the side queue may hold
stuff from outer parse steps we haveside_p
pointing at its top.
side_p
isside_n
- 1 - |elems-at-start| andSideOp(side_p)
is the
top-most operator pushed at the side queue.
This sounds like the Shunting-yard algorithm. Is it the same or a different algorithm?