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

Method parse_subscript

tools/inspector_protocol/jinja2/parser.py:696–720  ·  view source on GitHub ↗
(self, node)

Source from the content-addressed store, hash-verified

694 return node
695
696 def parse_subscript(self, node):
697 token = next(self.stream)
698 if token.type == 'dot':
699 attr_token = self.stream.current
700 next(self.stream)
701 if attr_token.type == 'name':
702 return nodes.Getattr(node, attr_token.value, 'load',
703 lineno=token.lineno)
704 elif attr_token.type != 'integer':
705 self.fail('expected name or number', attr_token.lineno)
706 arg = nodes.Const(attr_token.value, lineno=attr_token.lineno)
707 return nodes.Getitem(node, arg, 'load', lineno=token.lineno)
708 if token.type == 'lbracket':
709 args = []
710 while self.stream.current.type != 'rbracket':
711 if args:
712 self.stream.expect('comma')
713 args.append(self.parse_subscribed())
714 self.stream.expect('rbracket')
715 if len(args) == 1:
716 arg = args[0]
717 else:
718 arg = nodes.Tuple(args, 'load', lineno=token.lineno)
719 return nodes.Getitem(node, arg, 'load', lineno=token.lineno)
720 self.fail('expected subscript expression', self.lineno)
721
722 def parse_subscribed(self):
723 lineno = self.stream.current.lineno

Callers 1

parse_postfixMethod · 0.95

Calls 5

failMethod · 0.95
parse_subscribedMethod · 0.95
nextFunction · 0.50
expectMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected