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

Method parse_module_name

parser/src/parser/parser.rs:1474–1501  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

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> {

Callers 2

Calls 8

atMethod · 0.80
cur_kindMethod · 0.80
bump_anyMethod · 0.80
to_stringMethod · 0.80
cur_tokenMethod · 0.80
eatMethod · 0.80
as_strMethod · 0.80
expectMethod · 0.80

Tested by

no test coverage detected