| 559 | return self.parse_compare() |
| 560 | |
| 561 | def parse_compare(self) -> nodes.Expr: |
| 562 | lineno = self.stream.current.lineno |
| 563 | expr = self.parse_math1() |
| 564 | ops = [] |
| 565 | while True: |
| 566 | token_type = self.stream.current.type |
| 567 | if token_type in _compare_operators: |
| 568 | next(self.stream) |
| 569 | ops.append(nodes.Operand(token_type, self.parse_math1())) |
| 570 | elif self.stream.skip_if("name:in"): |
| 571 | ops.append(nodes.Operand("in", self.parse_math1())) |
| 572 | elif self.stream.current.test("name:not") and self.stream.look().test( |
| 573 | "name:in" |
| 574 | ): |
| 575 | self.stream.skip(2) |
| 576 | ops.append(nodes.Operand("notin", self.parse_math1())) |
| 577 | else: |
| 578 | break |
| 579 | lineno = self.stream.current.lineno |
| 580 | if not ops: |
| 581 | return expr |
| 582 | return nodes.Compare(expr, ops, lineno=lineno) |
| 583 | |
| 584 | def parse_math1(self) -> nodes.Expr: |
| 585 | lineno = self.stream.current.lineno |