gh-100239: specialize long tail of binary operations (#128722)

This commit is contained in:
Irit Katriel 2025-01-16 15:22:13 +00:00 committed by GitHub
parent e81fe940c9
commit 3893a92d95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 796 additions and 492 deletions

View file

@ -357,9 +357,12 @@ class Parser(PLexer):
def uop(self) -> UOp | None:
if tkn := self.expect(lx.IDENTIFIER):
if self.expect(lx.DIVIDE):
sign = 1
if negate := self.expect(lx.MINUS):
sign = -1
if num := self.expect(lx.NUMBER):
try:
size = int(num.text)
size = sign * int(num.text)
except ValueError:
raise self.make_syntax_error(
f"Expected integer, got {num.text!r}"