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

Method parse_match_statement

parser/src/parser/parser.rs:707–724  ·  view source on GitHub ↗

https://peps.python.org/pep-0622/#appendix-a-full-grammar

(&mut self)

Source from the content-addressed store, hash-verified

705
706 // https://peps.python.org/pep-0622/#appendix-a-full-grammar
707 fn parse_match_statement(&mut self) -> Result<Statement, ParsingError> {
708 let node = self.start_node();
709 // This identifier is match word
710 // match is a soft keyword
711 self.bump(Kind::Identifier);
712 let subject = self.parse_subject()?;
713 self.expect(Kind::Colon)?;
714 self.expect(Kind::NewLine)?;
715 self.expect(Kind::Indent)?;
716 let cases = self.parse_cases()?;
717 self.expect_any(vec![Kind::Dedent, Kind::Eof])?;
718
719 Ok(Statement::MatchStmt(Box::new(Match {
720 node: self.finish_node(node),
721 subject,
722 cases,
723 })))
724 }
725
726 // This is inaccuracy, but I don't know how
727 // the grammar should be

Callers 1

Calls 7

start_nodeMethod · 0.80
bumpMethod · 0.80
parse_subjectMethod · 0.80
expectMethod · 0.80
parse_casesMethod · 0.80
expect_anyMethod · 0.80
finish_nodeMethod · 0.80

Tested by

no test coverage detected