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

Method parse_subscript

deps/v8/third_party/jinja2/parser.py:799–828  ·  view source on GitHub ↗
(
        self, node: nodes.Expr
    )

Source from the content-addressed store, hash-verified

797 return node
798
799 def parse_subscript(
800 self, node: nodes.Expr
801 ) -> t.Union[nodes.Getattr, nodes.Getitem]:
802 token = next(self.stream)
803 arg: nodes.Expr
804
805 if token.type == "dot":
806 attr_token = self.stream.current
807 next(self.stream)
808 if attr_token.type == "name":
809 return nodes.Getattr(
810 node, attr_token.value, "load", lineno=token.lineno
811 )
812 elif attr_token.type != "integer":
813 self.fail("expected name or number", attr_token.lineno)
814 arg = nodes.Const(attr_token.value, lineno=attr_token.lineno)
815 return nodes.Getitem(node, arg, "load", lineno=token.lineno)
816 if token.type == "lbracket":
817 args: t.List[nodes.Expr] = []
818 while self.stream.current.type != "rbracket":
819 if args:
820 self.stream.expect("comma")
821 args.append(self.parse_subscribed())
822 self.stream.expect("rbracket")
823 if len(args) == 1:
824 arg = args[0]
825 else:
826 arg = nodes.Tuple(args, "load", lineno=token.lineno)
827 return nodes.Getitem(node, arg, "load", lineno=token.lineno)
828 self.fail("expected subscript expression", token.lineno)
829
830 def parse_subscribed(self) -> nodes.Expr:
831 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