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

Method macro_if

Tools/cases_generator/parsing.py:688–703  ·  view source on GitHub ↗
(self, cond: lx.Token)

Source from the content-addressed store, hash-verified

686 return IfStmt(if_, condition, body, else_, else_body)
687
688 def macro_if(self, cond: lx.Token) -> MacroIfStmt:
689 else_ = None
690 body: list[Stmt] = []
691 else_body: list[Stmt] | None = None
692 part = body
693 while True:
694 if tkn := self.expect(lx.CMACRO_ENDIF):
695 return MacroIfStmt(cond, body, else_, else_body, tkn)
696 elif tkn := self.expect(lx.CMACRO_ELSE):
697 if part is else_body:
698 raise self.make_syntax_error("Multiple #else")
699 else_ = tkn
700 else_body = []
701 part = else_body
702 else:
703 part.append(self.stmt())
704
705 def for_stmt(self, for_: lx.Token) -> ForStmt:
706 lparen = self.require(lx.LPAREN)

Callers 1

stmtMethod · 0.95

Calls 5

expectMethod · 0.95
make_syntax_errorMethod · 0.95
stmtMethod · 0.95
MacroIfStmtClass · 0.85
appendMethod · 0.45

Tested by

no test coverage detected