MCPcopy Index your code
hub / github.com/nodejs/node / parse_if

Method parse_if

deps/v8/third_party/jinja2/parser.py:253–269  ·  view source on GitHub ↗

Parse an if construct.

(self)

Source from the content-addressed store, hash-verified

251 return nodes.For(target, iter, body, else_, test, recursive, lineno=lineno)
252
253 def parse_if(self) -> nodes.If:
254 """Parse an if construct."""
255 node = result = nodes.If(lineno=self.stream.expect("name:if").lineno)
256 while True:
257 node.test = self.parse_tuple(with_condexpr=False)
258 node.body = self.parse_statements(("name:elif", "name:else", "name:endif"))
259 node.elif_ = []
260 node.else_ = []
261 token = next(self.stream)
262 if token.test("name:elif"):
263 node = nodes.If(lineno=self.stream.current.lineno)
264 result.elif_.append(node)
265 continue
266 elif token.test("name:else"):
267 result.else_ = self.parse_statements(("name:endif",), drop_needle=True)
268 break
269 return result
270
271 def parse_with(self) -> nodes.With:
272 node = nodes.With(lineno=next(self.stream).lineno)

Callers

nothing calls this directly

Calls 6

parse_tupleMethod · 0.95
parse_statementsMethod · 0.95
nextFunction · 0.50
expectMethod · 0.45
testMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected