| 470 | return self.parse_compare() |
| 471 | |
| 472 | def parse_compare(self): |
| 473 | lineno = self.stream.current.lineno |
| 474 | expr = self.parse_math1() |
| 475 | ops = [] |
| 476 | while 1: |
| 477 | token_type = self.stream.current.type |
| 478 | if token_type in _compare_operators: |
| 479 | next(self.stream) |
| 480 | ops.append(nodes.Operand(token_type, self.parse_math1())) |
| 481 | elif self.stream.skip_if('name:in'): |
| 482 | ops.append(nodes.Operand('in', self.parse_math1())) |
| 483 | elif (self.stream.current.test('name:not') and |
| 484 | self.stream.look().test('name:in')): |
| 485 | self.stream.skip(2) |
| 486 | ops.append(nodes.Operand('notin', self.parse_math1())) |
| 487 | else: |
| 488 | break |
| 489 | lineno = self.stream.current.lineno |
| 490 | if not ops: |
| 491 | return expr |
| 492 | return nodes.Compare(expr, ops, lineno=lineno) |
| 493 | |
| 494 | def parse_math1(self): |
| 495 | lineno = self.stream.current.lineno |