embedable block comment

def block_comment(solver, start, end):
  '''embedable block comment'''
  text, pos = solver.parse_state
  length = len(text)
  startlen = len(start)
  endlen = len(end)
  if pos==length: return
  if not text[pos:].startswith(start):
    return
  level = 1
  p = pos+1
  while p<length:
    if text[p:].startswith(end):
      level -= 1
      p += endlen
      if level==0: break
    elif text[p:].startswith(start):
      level += 1
      p += startlen
    else:
      p += 1
  else: return
  solver.parse_state = text, p
  yield cont, text[pos:p]
  solver.parse_state = text, pos