let terminate_blocks blocks =
    let rec block_terminate rblocks = function
        | (n, toks, false)::rest ->
            let terminated = if (needs_semi toks) then toks@[SEMIelse toks in
            block_terminate ((n, terminated, false)::rblocks) rest
        | other::rest ->
            block_terminate (other::rblocks) rest
        | [] -> List.rev rblocks in
    block_terminate [] blocks