| 1472 | } |
| 1473 | |
| 1474 | fn parse_module_name(&mut self) -> Result<(String, usize), ParsingError> { |
| 1475 | let mut level = 0; |
| 1476 | while self.at(Kind::Dot) | self.at(Kind::Ellipsis) { |
| 1477 | match self.cur_kind() { |
| 1478 | Kind::Dot => { |
| 1479 | level += 1; |
| 1480 | } |
| 1481 | Kind::Ellipsis => { |
| 1482 | level += 3; |
| 1483 | } |
| 1484 | _ => { |
| 1485 | panic!("lol"); |
| 1486 | } |
| 1487 | } |
| 1488 | self.bump_any(); |
| 1489 | } |
| 1490 | let mut module = String::from(""); |
| 1491 | if self.at(Kind::Identifier) { |
| 1492 | module += &self.cur_token().to_string(self.source); |
| 1493 | self.bump_any(); |
| 1494 | while self.eat(Kind::Dot) { |
| 1495 | module.push('.'); |
| 1496 | module.push_str(self.cur_token().as_str(self.source)); |
| 1497 | self.expect(Kind::Identifier); |
| 1498 | } |
| 1499 | } |
| 1500 | Ok((module, level)) |
| 1501 | } |
| 1502 | |
| 1503 | // https://docs.python.org/3/library/ast.html#ast.Expr |
| 1504 | fn parse_expressions(&mut self) -> Result<Expression, ParsingError> { |