fn parse_iter(&mut self) -> WeldResult<Iter> {
        let iter: Token = self.peek().clone();
        match iter {
            TScalarIter | TSimdIter | TFringeIter | TNdIter => {
                self.consume(iter.clone())?;
                self.consume(TOpenParen)?;
                let data = self.expr()?;
                let (mut start, mut end, mut stride, mut shape, mut strides) =
                    (None, None, None, None, None);

                if *self.peek() == TComma {
                    self.consume(TComma)?;
                    start = Some(self.expr()?);
                    self.consume(TComma)?;
                    end = Some(self.expr()?);
                    self.consume(TComma)?;
                    stride = Some(self.expr()?);
                }

                if iter == TNdIter && *self.peek() == TComma {
                    self.consume(TComma)?;
                    shape = Some(self.expr()?);
                    self.consume(TComma)?;
                    strides = Some(self.expr()?);
                }

                let iter = Iter {
                    data,
                    start,
                    end,
                    stride,
                    kind: match iter {
                        TSimdIter => SimdIter,
                        TFringeIter => FringeIter,
                        TNdIter => NdIter,
                        _ => ScalarIter,
                    },
                    shape,
                    strides,
                };
                self.consume(TCloseParen)?;
                Ok(iter)
            }
            TRangeIter => {
                self.consume(iter)?;
                self.consume(TOpenParen)?;
                let start = self.expr()?;
                self.consume(TComma)?;
                let end = self.expr()?;
                self.consume(TComma)?;
                let stride = self.expr()?;
                let mut dummy_data = expr_box(MakeVector { elems: vec![] }, Annotations::new());
                dummy_data.as_mut().ty = Vector(Box::new(Scalar(ScalarKind::I64)));
                let iter = Iter {
                    data: dummy_data,
                    start: Some(start),
                    end: Some(end),
                    stride: Some(stride),
                    kind: RangeIter,
                    shape: None,
                    strides: None,
                };
                self.consume(TCloseParen)?;
                Ok(iter)
            }
            _ => {
                let data = self.expr()?;
                let iter = Iter {
                    data,
                    start: None,
                    end: None,
                    stride: None,
                    kind: match iter {
                        TSimdIter => SimdIter,
                        TFringeIter => FringeIter,
                        TNdIter => NdIter,
                        TRangeIter => RangeIter,
                        _ => ScalarIter,
                    },
                    shape: None,
                    strides: None,
                };
                Ok(iter)
            }
        }
    }
Parses a for loop iterator expression starting at the current position. This could also be
a vector expression (i.e., without an explicit iter(..).
weld/src/syntax/parser.rs