def METHOD_NAME(p, token, left, unused_bp):
  """ index f[x+1] """
  # f[x] or f[x][y]
  if not isinstance(left, demo_asdl.ArithVar):
    raise tdop.ParseError("%s can't be indexed" % left)
  index = p.ParseUntil(0)
  if p.AtToken(':'):
    p.Next()
    end = p.ParseUntil(0)
  else:
    end = None
  p.Eat(']')
  # TODO: If you see ], then
  # 1:4
  # 1:4:2
  # Both end and step are optional
  if end:
    return demo_asdl.Slice(left, index, end, None)
  else:
    return demo_asdl.Index(left, index)