Parse an if construct.
(self)
| 205 | recursive, lineno=lineno) |
| 206 | |
| 207 | def parse_if(self): |
| 208 | """Parse an if construct.""" |
| 209 | node = result = nodes.If(lineno=self.stream.expect('name:if').lineno) |
| 210 | while 1: |
| 211 | node.test = self.parse_tuple(with_condexpr=False) |
| 212 | node.body = self.parse_statements(('name:elif', 'name:else', |
| 213 | 'name:endif')) |
| 214 | node.elif_ = [] |
| 215 | node.else_ = [] |
| 216 | token = next(self.stream) |
| 217 | if token.test('name:elif'): |
| 218 | node = nodes.If(lineno=self.stream.current.lineno) |
| 219 | result.elif_.append(node) |
| 220 | continue |
| 221 | elif token.test('name:else'): |
| 222 | result.else_ = self.parse_statements(('name:endif',), |
| 223 | drop_needle=True) |
| 224 | break |
| 225 | return result |
| 226 | |
| 227 | def parse_with(self): |
| 228 | node = nodes.With(lineno=next(self.stream).lineno) |
nothing calls this directly
no test coverage detected