(self)
| 642 | return node |
| 643 | |
| 644 | def parse_primary(self) -> nodes.Expr: |
| 645 | token = self.stream.current |
| 646 | node: nodes.Expr |
| 647 | if token.type == "name": |
| 648 | if token.value in ("true", "false", "True", "False"): |
| 649 | node = nodes.Const(token.value in ("true", "True"), lineno=token.lineno) |
| 650 | elif token.value in ("none", "None"): |
| 651 | node = nodes.Const(None, lineno=token.lineno) |
| 652 | else: |
| 653 | node = nodes.Name(token.value, "load", lineno=token.lineno) |
| 654 | next(self.stream) |
| 655 | elif token.type == "string": |
| 656 | next(self.stream) |
| 657 | buf = [token.value] |
| 658 | lineno = token.lineno |
| 659 | while self.stream.current.type == "string": |
| 660 | buf.append(self.stream.current.value) |
| 661 | next(self.stream) |
| 662 | node = nodes.Const("".join(buf), lineno=lineno) |
| 663 | elif token.type in ("integer", "float"): |
| 664 | next(self.stream) |
| 665 | node = nodes.Const(token.value, lineno=token.lineno) |
| 666 | elif token.type == "lparen": |
| 667 | next(self.stream) |
| 668 | node = self.parse_tuple(explicit_parentheses=True) |
| 669 | self.stream.expect("rparen") |
| 670 | elif token.type == "lbracket": |
| 671 | node = self.parse_list() |
| 672 | elif token.type == "lbrace": |
| 673 | node = self.parse_dict() |
| 674 | else: |
| 675 | self.fail(f"unexpected {describe_token(token)!r}", token.lineno) |
| 676 | return node |
| 677 | |
| 678 | def parse_tuple( |
| 679 | self, |
no test coverage detected