A partial reduce-action sync with decompyle3

Start us add _check prefixes and _invalid to the end of check methods
This commit is contained in:
rocky
2022-09-30 02:45:52 -04:00
parent 3bd3029169
commit 2264ccb1d5
7 changed files with 33 additions and 28 deletions

View File

@@ -653,10 +653,10 @@ class Python2Parser(PythonParser):
pass
self.reduce_check_table = {
# "and": and_check,
# "and": and_invalid,
"except_handler_else": except_handler_else,
"ifelsestmt": ifelsestmt,
# "or": or_check,
# "or": or_invalid,
"tryelsestmt": tryelsestmt,
"tryelsestmtl": tryelsestmt,
}

View File

@@ -30,7 +30,7 @@ import re
from uncompyle6.scanners.tok import Token
from uncompyle6.parser import PythonParser, PythonParserSingle, nop_func
from uncompyle6.parsers.reducecheck import (
and_check,
and_invalid,
except_handler_else,
ifelsestmt,
ifstmt,
@@ -1581,7 +1581,7 @@ class Python3Parser(PythonParser):
}
if self.version == (3, 6):
self.reduce_check_table["and"] = and_check
self.reduce_check_table["and"] = and_invalid
self.check_reduce["and"] = "AST"
self.check_reduce["annotate_tuple"] = "noAST"

View File

@@ -8,7 +8,7 @@ from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
from spark_parser.spark import rule2str
from uncompyle6.parsers.reducecheck import (
and_check,
and_invalid,
ifelsestmt,
iflaststmt,
ifstmt,
@@ -1128,7 +1128,7 @@ class Python37BaseParser(PythonParser):
self.reduce_check_table = {
"_ifstmts_jump": ifstmts_jump,
"and": and_check,
"and": and_invalid,
"ifelsestmt": ifelsestmt,
"ifelsestmtl": ifelsestmt,
"iflaststmt": iflaststmt,

View File

@@ -20,7 +20,6 @@ from __future__ import print_function
from uncompyle6.parser import PythonParserSingle, nop_func
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
from uncompyle6.parsers.parse37 import Python37Parser
from uncompyle6.parsers.reducecheck import joined_str_check
class Python38Parser(Python37Parser):
def p_38_stmt(self, args):

View File

@@ -1,18 +1,18 @@
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 *
from uncompyle6.parsers.reducecheck.ifelsestmt2 import *
from uncompyle6.parsers.reducecheck.iflaststmt import *
from uncompyle6.parsers.reducecheck.ifstmt import *
from uncompyle6.parsers.reducecheck.ifstmt2 import *
from uncompyle6.parsers.reducecheck.ifstmts_jump import *
from uncompyle6.parsers.reducecheck.for_block_check import *
from uncompyle6.parsers.reducecheck.or_check import *
from uncompyle6.parsers.reducecheck.testtrue import *
from uncompyle6.parsers.reducecheck.tryelsestmt import *
from uncompyle6.parsers.reducecheck.tryexcept import *
from uncompyle6.parsers.reducecheck.tryelsestmtl3 import *
from uncompyle6.parsers.reducecheck.while1elsestmt import *
from uncompyle6.parsers.reducecheck.while1stmt import *
from uncompyle6.parsers.reducecheck.and_check import * # noqa
from uncompyle6.parsers.reducecheck.aug_assign import * # noqa
from uncompyle6.parsers.reducecheck.except_handler import * # noqa
from uncompyle6.parsers.reducecheck.except_handler_else import * # noqa
from uncompyle6.parsers.reducecheck.ifelsestmt import * # noqa
from uncompyle6.parsers.reducecheck.ifelsestmt2 import * # noqa
from uncompyle6.parsers.reducecheck.iflaststmt import * # noqa
from uncompyle6.parsers.reducecheck.ifstmt import * # noqa
from uncompyle6.parsers.reducecheck.ifstmt2 import * # noqa
from uncompyle6.parsers.reducecheck.ifstmts_jump import * # noqa
from uncompyle6.parsers.reducecheck.for_block_check import * # noqa
from uncompyle6.parsers.reducecheck.or_check import * # noqa
from uncompyle6.parsers.reducecheck.testtrue import * # noqa
from uncompyle6.parsers.reducecheck.tryelsestmt import * # noqa
from uncompyle6.parsers.reducecheck.tryexcept import * # noqa
from uncompyle6.parsers.reducecheck.tryelsestmtl3 import * # noqa
from uncompyle6.parsers.reducecheck.while1elsestmt import * # noqa
from uncompyle6.parsers.reducecheck.while1stmt import * # noqa

View File

@@ -1,7 +1,13 @@
# Copyright (c) 2020 Rocky Bernstein
# Copyright (c) 2020, 2022 Rocky Bernstein
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
def and_check(self, lhs, n, rule, ast, tokens, first, last):
def and_invalid(
self, lhs: str, n: int, rule, ast, tokens: list, first: int, last: int
) -> bool:
jmp = ast[1]
if jmp.kind.startswith("jmp_"):
if last == n:

View File

@@ -13,7 +13,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
def joined_str_ok(
def joined_str_invalid(
self, lhs: str, n: int, rule, tree, tokens: list, first: int, last: int
) -> bool:
# In Python 3.8, there is a new "=" specifier.