(self)
| 550 | return node |
| 551 | |
| 552 | def parse_primary(self): |
| 553 | token = self.stream.current |
| 554 | if token.type == 'name': |
| 555 | if token.value in ('true', 'false', 'True', 'False'): |
| 556 | node = nodes.Const(token.value in ('true', 'True'), |
| 557 | lineno=token.lineno) |
| 558 | elif token.value in ('none', 'None'): |
| 559 | node = nodes.Const(None, lineno=token.lineno) |
| 560 | else: |
| 561 | node = nodes.Name(token.value, 'load', lineno=token.lineno) |
| 562 | next(self.stream) |
| 563 | elif token.type == 'string': |
| 564 | next(self.stream) |
| 565 | buf = [token.value] |
| 566 | lineno = token.lineno |
| 567 | while self.stream.current.type == 'string': |
| 568 | buf.append(self.stream.current.value) |
| 569 | next(self.stream) |
| 570 | node = nodes.Const(''.join(buf), lineno=lineno) |
| 571 | elif token.type in ('integer', 'float'): |
| 572 | next(self.stream) |
| 573 | node = nodes.Const(token.value, lineno=token.lineno) |
| 574 | elif token.type == 'lparen': |
| 575 | next(self.stream) |
| 576 | node = self.parse_tuple(explicit_parentheses=True) |
| 577 | self.stream.expect('rparen') |
| 578 | elif token.type == 'lbracket': |
| 579 | node = self.parse_list() |
| 580 | elif token.type == 'lbrace': |
| 581 | node = self.parse_dict() |
| 582 | else: |
| 583 | self.fail("unexpected '%s'" % describe_token(token), token.lineno) |
| 584 | return node |
| 585 | |
| 586 | def parse_tuple(self, simplified=False, with_condexpr=True, |
| 587 | extra_end_rules=None, explicit_parentheses=False): |
no test coverage detected