Fix bug introduced by a recent refactoring

This commit is contained in:
rocky
2020-01-24 03:11:51 -05:00
parent 7e91daf043
commit 4067a30573
4 changed files with 4 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
# Copyright (c) 2020 Rocky Bernstein
def ifstmt(self, lhs, n, rule, ast, tokens, first, last):
if lhs == "ifstmtl":
if last == n:
@@ -48,9 +49,9 @@ def ifstmt(self, lhs, n, rule, ast, tokens, first, last):
if len(test) > 1 and test[1].kind.startswith("jmp_"):
jmp_target = test[1][0].attr
if (
tokens[first].off2int(True)
tokens[first].off2int(prefer_last=True)
<= jmp_target
< tokens[last].off2int(False)
< tokens[last].off2int(prefer_last=False)
):
return True
# jmp_target less than tokens[first] is okay - is to a loop

View File

@@ -187,7 +187,7 @@ class Token:
raise IndexError
def off2int(self, prefer_last=True):
return off2int(self.offset)
return off2int(self.offset, prefer_last)
NoneToken = Token("LOAD_CONST", offset=-1, attr=None, pattr=None)