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

Method parse_except_clauses

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

Source from the content-addressed store, hash-verified

557 }
558
559 fn parse_except_clauses(&mut self) -> Result<Vec<ExceptHandler>, ParsingError> {
560 let mut handlers = vec![];
561 while self.at(Kind::Except) {
562 let node = self.start_node();
563 self.bump(Kind::Except);
564 self.bump(Kind::Mul);
565 let typ = if !self.at(Kind::Colon) {
566 Some(self.parse_expression()?)
567 } else {
568 None
569 };
570 let name = if self.eat(Kind::As) {
571 let val = Some(self.cur_token().to_string(self.source));
572 self.bump(Kind::Identifier);
573 val
574 } else {
575 None
576 };
577
578 self.expect(Kind::Colon)?;
579 let body = self.parse_suite()?;
580
581 handlers.push(ExceptHandler {
582 node: self.finish_node_chomped(node),
583 typ,
584 name,
585 body,
586 });
587 }
588
589 Ok(handlers)
590 }
591
592 fn parse_function_definition(
593 &mut self,

Callers 1

parse_try_statementMethod · 0.80

Calls 10

atMethod · 0.80
start_nodeMethod · 0.80
bumpMethod · 0.80
parse_expressionMethod · 0.80
eatMethod · 0.80
to_stringMethod · 0.80
cur_tokenMethod · 0.80
expectMethod · 0.80
parse_suiteMethod · 0.80
finish_node_chompedMethod · 0.80

Tested by

no test coverage detected