MCPcopy Create free account
hub / github.com/Glyphack/enderpy / parse_slices

Method parse_slices

parser/src/parser/parser.rs:2914–2936  ·  view source on GitHub ↗

https://docs.python.org/3/reference/expressions.html#slicings Closing will be consumed by this function

(&mut self)

Source from the content-addressed store, hash-verified

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();

Callers 1

parse_subscriptMethod · 0.80

Calls 9

TupleClass · 0.85
start_nodeMethod · 0.80
atMethod · 0.80
parse_sliceMethod · 0.80
eatMethod · 0.80
expectMethod · 0.80
finish_nodeMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected