Tangle -- The big output switch

In the previous part we saw that the token stream is turned into an output buffer + some state (basically a queue), by calling three functions send_out, send_val, and send_sign.

In this part we’ll see exactly when those three functions are called respectively (and with what arguments), i.e. the complex rules on what happens if Token X is followed by Token Y are all here.

The cases are:














The above is incomplete in details (just read the code below), and can probably be better presented as a table of: if you’ve just seen token X, and you see token Y, what should you do.