Helper for creating lexer functions