MCPcopy Index your code
hub / github.com/python/cpython / stmt

Method stmt

Tools/cases_generator/parsing.py:649–673  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

647 return BlockStmt(open, stmts, close)
648
649 def stmt(self) -> Stmt:
650 if tkn := self.expect(lx.IF):
651 return self.if_stmt(tkn)
652 elif self.expect(lx.LBRACE):
653 self.backup()
654 return self.block()
655 elif tkn := self.expect(lx.FOR):
656 return self.for_stmt(tkn)
657 elif tkn := self.expect(lx.WHILE):
658 return self.while_stmt(tkn)
659 elif tkn := self.expect(lx.CMACRO_IF):
660 return self.macro_if(tkn)
661 elif tkn := self.expect(lx.CMACRO_ELSE):
662 msg = "Unexpected #else"
663 raise self.make_syntax_error(msg)
664 elif tkn := self.expect(lx.CMACRO_ENDIF):
665 msg = "Unexpected #endif"
666 raise self.make_syntax_error(msg)
667 elif tkn := self.expect(lx.CMACRO_OTHER):
668 return SimpleStmt([tkn])
669 elif tkn := self.expect(lx.SWITCH):
670 msg = "switch statements are not supported due to their complex flow control. Sorry."
671 raise self.make_syntax_error(msg)
672 tokens = self.consume_to(lx.SEMI)
673 return SimpleStmt(tokens)
674
675 def if_stmt(self, if_: lx.Token) -> IfStmt:
676 lparen = self.require(lx.LPAREN)

Callers 2

blockMethod · 0.95
macro_ifMethod · 0.95

Calls 10

expectMethod · 0.95
if_stmtMethod · 0.95
blockMethod · 0.95
for_stmtMethod · 0.95
while_stmtMethod · 0.95
macro_ifMethod · 0.95
make_syntax_errorMethod · 0.95
SimpleStmtClass · 0.85
backupMethod · 0.80
consume_toMethod · 0.80

Tested by

no test coverage detected