def something(TokenClass):
 def callback(lexer, match, context):
  text = match.group()
  if (not text):
   return
  (yield (match.start(), TokenClass, text))
  context.pos = match.end()
 return callback

def something ( TokenClass ) : def callback ( lexer , match , context ) : text = match . group ( ) if ( not text ) : return ( yield ( match . start ( ) , TokenClass , text ) ) context . pos = match . end ( ) return callback
do not produce empty tokens .