You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
24 lines
764 B
Python
24 lines
764 B
Python
# Copyright (c) 2020 Rocky Bernstein
|
|
|
|
|
|
def while1elsestmt(self, lhs, n, rule, ast, tokens, first, last):
|
|
if last == n:
|
|
# Adjust for fuzziness in parsing
|
|
last -= 1
|
|
|
|
if tokens[last] == "COME_FROM_LOOP":
|
|
last -= 1
|
|
elif tokens[last - 1] == "COME_FROM_LOOP":
|
|
last -= 2
|
|
if tokens[last] in ("JUMP_BACK", "CONTINUE"):
|
|
# These indicate inside a loop, but token[last]
|
|
# should not be in a loop.
|
|
# FIXME: Not quite right: refine by using target
|
|
return True
|
|
|
|
# if SETUP_LOOP target spans the else part, then this is
|
|
# not while1else. Also do for whileTrue?
|
|
last += 1
|
|
# 3.8+ Doesn't have SETUP_LOOP
|
|
return self.version < (3, 8) and tokens[first].attr > tokens[last].off2int()
|