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

Method if_stmt

Tools/cases_generator/parsing.py:675–686  ·  view source on GitHub ↗
(self, if_: lx.Token)

Source from the content-addressed store, hash-verified

673 return SimpleStmt(tokens)
674
675 def if_stmt(self, if_: lx.Token) -> IfStmt:
676 lparen = self.require(lx.LPAREN)
677 condition = [lparen] + self.consume_to(lx.RPAREN)
678 body = self.block()
679 else_body: Stmt | None = None
680 else_: lx.Token | None = None
681 if else_ := self.expect(lx.ELSE):
682 if inner := self.expect(lx.IF):
683 else_body = self.if_stmt(inner)
684 else:
685 else_body = self.block()
686 return IfStmt(if_, condition, body, else_, else_body)
687
688 def macro_if(self, cond: lx.Token) -> MacroIfStmt:
689 else_ = None

Callers 1

stmtMethod · 0.95

Calls 5

blockMethod · 0.95
expectMethod · 0.95
IfStmtClass · 0.85
requireMethod · 0.80
consume_toMethod · 0.80

Tested by

no test coverage detected