From 5079164db237005f271f55fe5207b45573ee0f23 Mon Sep 17 00:00:00 2001 From: rocky Date: Tue, 7 Jul 2020 08:20:09 -0400 Subject: [PATCH] Add reduce check for aug_assign1 --- uncompyle6/parsers/parse27.py | 3 +++ uncompyle6/parsers/reducecheck/__init__.py | 1 + uncompyle6/parsers/reducecheck/aug_assign.py | 10 ++++++++++ 3 files changed, 14 insertions(+) create mode 100644 uncompyle6/parsers/reducecheck/aug_assign.py diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index 9082e997..2b7d83c8 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -7,6 +7,7 @@ from xdis import next_offset from uncompyle6.parser import PythonParserSingle, nop_func from uncompyle6.parsers.parse2 import Python2Parser from uncompyle6.parsers.reducecheck import ( + aug_assign1_check, or_check, tryelsestmt, except_handler, @@ -231,6 +232,7 @@ class Python27Parser(Python2Parser): # FIXME: Put more in this table self.reduce_check_table = { # "ifelsestmt": ifelsestmt, + "aug_assign1": aug_assign1_check, "except_handler": except_handler, "or": or_check, "tryelsestmt": tryelsestmt, @@ -238,6 +240,7 @@ class Python27Parser(Python2Parser): } self.check_reduce["and"] = "AST" + self.check_reduce["aug_assign1"] = "AST" self.check_reduce["if_exp"] = "AST" self.check_reduce["except_handler"] = "tokens" diff --git a/uncompyle6/parsers/reducecheck/__init__.py b/uncompyle6/parsers/reducecheck/__init__.py index e7eafa3f..a2bf8bb4 100644 --- a/uncompyle6/parsers/reducecheck/__init__.py +++ b/uncompyle6/parsers/reducecheck/__init__.py @@ -1,4 +1,5 @@ from uncompyle6.parsers.reducecheck.and_check import * +from uncompyle6.parsers.reducecheck.aug_assign import * from uncompyle6.parsers.reducecheck.except_handler import * from uncompyle6.parsers.reducecheck.except_handler_else import * from uncompyle6.parsers.reducecheck.ifelsestmt import * diff --git a/uncompyle6/parsers/reducecheck/aug_assign.py b/uncompyle6/parsers/reducecheck/aug_assign.py new file mode 100644 index 00000000..6e74319b --- /dev/null +++ b/uncompyle6/parsers/reducecheck/aug_assign.py @@ -0,0 +1,10 @@ +# Copyright (c) 2020 Rocky Bernstein + +def aug_assign1_check(self, lhs, n, rule, ast, tokens, first, last): + # print("XXX", first, last, rule) + # for t in range(first, last): print(tokens[t]) + # print("="*40) + + expr = ast[0] + return expr == "expr" and expr[0] == "or" + return False