def dissect_index_expr(self, expr):

    if isinstance(expr.index.type, TupleT):
      indices = self.tuple_elts(expr.index)
    else:
      indices = [expr.index]
    
    n_dims = expr.value.type.rank 
    n_indices = len(indices)
    assert n_dims >= n_indices, \
      "Not yet supported: more indices (%d) than dimensions (%d) in %s" % (n_indices, n_dims, expr) 
    if n_indices < n_dims:
      indices = indices + [slice_none] * (n_dims - n_indices)
    
    if all_scalars(indices):
      # if there aren't any slice expressions, don't bother with the rest of this function
      return indices, range(len(indices)), [], []
    
    shape = self.shape(expr.value)
    shape_elts = self.tuple_elts(shape)
    slices = []
    slice_positions = []
    scalar_indices = []
    scalar_index_positions = []
    
    for i, shape_elt in enumerate(shape_elts):
      idx = indices[i]
      t = idx.type
      if isinstance(t, ScalarT):
        scalar_indices.append(idx)
        scalar_index_positions.append(i)
      elif isinstance(t, NoneT):
        slices.append( (zero_i64, shape_elt, one_i64) )
        slice_positions.append(i)
      else:
        assert isinstance(t, SliceT), "Unexpected index type: %s in %s" % (t, expr) 
        start = zero_i64 if t.start_type == NoneType else self.attr(idx, 'start')
        stop = shape_elt if t.stop_type == NoneType else self.attr(idx, 'stop')
        step = one_i64 if t.step_type == NoneType else self.attr(idx, 'step')
        slices.append( (start, stop, step) )
        slice_positions.append(i)   
    return scalar_indices, scalar_index_positions, slices, slice_positions
Split up an indexing expression into 
dataset/ETHPy150Open iskandr/parakeet/parakeet/transforms/lower_slices.py/LowerSlices.dissect_index_expr