There exists a few macro tutorials... But as I am not really good with macros I would try something like let h = case l.ch of '+': tkPlus of '-': tkMinus ... tok = Token(h, Literal: $l.ch ) Run
You may not even need a case statement, I think ascii characters are valid for array index, so you may use an array with tk*** content?