def augParseCategory(line, primitives, families, var=None):
 (cat_string, rest) = nextCategory(line)
 if cat_string.startswith(u'('):
  (res, var) = augParseCategory(cat_string[1:(-1)], primitives, families, var)
 else:
  (res, var) = parsePrimitiveCategory(PRIM_RE.match(cat_string).groups(), primitives, families, var)
 while (rest != u''):
  app = APP_RE.match(rest).groups()
  direction = parseApplication(app[0:3])
  rest = app[3]
  (cat_string, rest) = nextCategory(rest)
  if cat_string.startswith(u'('):
   (arg, var) = augParseCategory(cat_string[1:(-1)], primitives, families, var)
  else:
   (arg, var) = parsePrimitiveCategory(PRIM_RE.match(cat_string).groups(), primitives, families, var)
  res = FunctionalCategory(res, arg, direction)
 return (res, var)

def augParseCategory ( line , primitives , families , var = None ) : ( cat_string , rest ) = nextCategory ( line ) if cat_string . startswith ( u'(' ) : ( res , var ) = augParseCategory ( cat_string [ 1 : ( - 1 ) ] , primitives , families , var ) else : ( res , var ) = parsePrimitiveCategory ( PRIM_RE . match ( cat_string ) . groups ( ) , primitives , families , var ) while ( rest != u'' ) : app = APP_RE . match ( rest ) . groups ( ) direction = parseApplication ( app [ 0 : 3 ] ) rest = app [ 3 ] ( cat_string , rest ) = nextCategory ( rest ) if cat_string . startswith ( u'(' ) : ( arg , var ) = augParseCategory ( cat_string [ 1 : ( - 1 ) ] , primitives , families , var ) else : ( arg , var ) = parsePrimitiveCategory ( PRIM_RE . match ( cat_string ) . groups ( ) , primitives , families , var ) res = FunctionalCategory ( res , arg , direction ) return ( res , var )
parse a string representing a category .