def METHOD_NAME(lines):
  """find the next class definition C"""
  # .DIME -- find next DEFINE_CLASS
  for l in lines:
    match_D = term_D.patt.search(l)
    if match_D != None:
      break
    for t in (term_I, term_M):
      match = t.patt.search(l)
      if match != None:
        print "ERROR parsing .DIME: got I or M: ", l
        raise
  else:
    raise NoMoreInput()
  # with match_D
  #term_D.show(match_D)
  C = MPSClass(match_D)
  # D.IME -- find next InheritFrom, Mixin, or End
  for l in lines:
    for t in (term_D, term_I, term_M, term_E):
      match = t.patt.search(l)
      if match != None:
        break
    else:
      continue
    # with t
    #t.show(match)
    if t == term_D:
      print "ERROR parsing D.IME: got (another) D; expected I, M, or E"
      raise
    elif t == term_I:
      C.add_I(match)
    elif t == term_M:
      C.add_M(match)
    elif t == term_E:
      return C
  else:
    raise NoMoreInput()