scanner: improve token conversion