def parsePrimitiveCategory(chunks, primitives, families, var):
 if (chunks[0] == u'var'):
  if (chunks[1] is None):
   if (var is None):
    var = CCGVar()
   return (var, var)
 catstr = chunks[0]
 if (catstr in families):
  (cat, cvar) = families[catstr]
  if (var is None):
   var = cvar
  else:
   cat = cat.substitute([(cvar, var)])
  return (cat, var)
 if (catstr in primitives):
  subscrs = parseSubscripts(chunks[1])
  return (PrimitiveCategory(catstr, subscrs), var)
 raise AssertionError(((u"String '" + catstr) + u"' is neither a family nor primitive category."))

def parsePrimitiveCategory ( chunks , primitives , families , var ) : if ( chunks [ 0 ] == u'var' ) : if ( chunks [ 1 ] is None ) : if ( var is None ) : var = CCGVar ( ) return ( var , var ) catstr = chunks [ 0 ] if ( catstr in families ) : ( cat , cvar ) = families [ catstr ] if ( var is None ) : var = cvar else : cat = cat . substitute ( [ ( cvar , var ) ] ) return ( cat , var ) if ( catstr in primitives ) : subscrs = parseSubscripts ( chunks [ 1 ] ) return ( PrimitiveCategory ( catstr , subscrs ) , var ) raise AssertionError ( ( ( u"String '" + catstr ) + u"' is neither a family nor primitive category." ) )
parse a primitive category if the primitive is the special category var .