https://docs.python.org/3/reference/expressions.html#slicings Closing will be consumed by this function
(&mut self)
| 2912 | // https://docs.python.org/3/reference/expressions.html#slicings |
| 2913 | // Closing will be consumed by this function |
| 2914 | fn parse_slices(&mut self) -> Result<Expression, ParsingError> { |
| 2915 | let node = self.start_node(); |
| 2916 | |
| 2917 | let mut elements: Vec<Expression> = vec![]; |
| 2918 | while !self.at(Kind::RightBrace) { |
| 2919 | if self.at(Kind::Mul) { |
| 2920 | elements.push(self.parse_starred_expression_real()?); |
| 2921 | continue; |
| 2922 | } |
| 2923 | elements.push(self.parse_slice()?); |
| 2924 | if !self.eat(Kind::Comma) { |
| 2925 | break; |
| 2926 | } |
| 2927 | } |
| 2928 | self.expect(Kind::RightBrace)?; |
| 2929 | if elements.len() == 1 { |
| 2930 | return Ok(elements.pop().unwrap()); |
| 2931 | } |
| 2932 | Ok(Expression::Tuple(Box::new(Tuple { |
| 2933 | node: self.finish_node(node), |
| 2934 | elements, |
| 2935 | }))) |
| 2936 | } |
| 2937 | |
| 2938 | fn parse_slice(&mut self) -> Result<Expression, ParsingError> { |
| 2939 | let node = self.start_node(); |
no test coverage detected