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

Method parse_assign_target

tools/inspector_protocol/jinja2/parser.py:396–424  ·  view source on GitHub ↗

Parse an assignment target. As Jinja2 allows assignments to tuples, this function can parse all allowed assignment targets. Per default assignments to tuples are parsed, that can be disable however by setting `with_tuple` to `False`. If only assignments to names are

(self, with_tuple=True, name_only=False,
                            extra_end_rules=None, with_namespace=False)

Source from the content-addressed store, hash-verified

394 return node
395
396 def parse_assign_target(self, with_tuple=True, name_only=False,
397 extra_end_rules=None, with_namespace=False):
398 """Parse an assignment target. As Jinja2 allows assignments to
399 tuples, this function can parse all allowed assignment targets. Per
400 default assignments to tuples are parsed, that can be disable however
401 by setting `with_tuple` to `False`. If only assignments to names are
402 wanted `name_only` can be set to `True`. The `extra_end_rules`
403 parameter is forwarded to the tuple parsing function. If
404 `with_namespace` is enabled, a namespace assignment may be parsed.
405 """
406 if with_namespace and self.stream.look().type == 'dot':
407 token = self.stream.expect('name')
408 next(self.stream) # dot
409 attr = self.stream.expect('name')
410 target = nodes.NSRef(token.value, attr.value, lineno=token.lineno)
411 elif name_only:
412 token = self.stream.expect('name')
413 target = nodes.Name(token.value, 'store', lineno=token.lineno)
414 else:
415 if with_tuple:
416 target = self.parse_tuple(simplified=True,
417 extra_end_rules=extra_end_rules)
418 else:
419 target = self.parse_primary()
420 target.set_ctx('store')
421 if not target.can_assign():
422 self.fail('can\'t assign to %r' % target.__class__.
423 __name__.lower(), target.lineno)
424 return target
425
426 def parse_expression(self, with_condexpr=True):
427 """Parse an expression. Per default all expressions are parsed, if

Callers 7

parse_setMethod · 0.95
parse_forMethod · 0.95
parse_withMethod · 0.95
parse_importMethod · 0.95
parse_fromMethod · 0.95
parse_signatureMethod · 0.95
parse_macroMethod · 0.95

Calls 9

parse_tupleMethod · 0.95
parse_primaryMethod · 0.95
can_assignMethod · 0.95
failMethod · 0.95
nextFunction · 0.50
lookMethod · 0.45
expectMethod · 0.45
NameMethod · 0.45
set_ctxMethod · 0.45

Tested by

no test coverage detected