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