You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
2.7 tryelse rule check disambiguation.
This commit is contained in:
@@ -6,7 +6,10 @@ from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
|||||||
from xdis import next_offset
|
from xdis import next_offset
|
||||||
from uncompyle6.parser import PythonParserSingle, nop_func
|
from uncompyle6.parser import PythonParserSingle, nop_func
|
||||||
from uncompyle6.parsers.parse2 import Python2Parser
|
from uncompyle6.parsers.parse2 import Python2Parser
|
||||||
from uncompyle6.parsers.reducecheck import ifelsestmt
|
from uncompyle6.parsers.reducecheck import (
|
||||||
|
ifelsestmt,
|
||||||
|
tryelsestmt,
|
||||||
|
)
|
||||||
|
|
||||||
class Python27Parser(Python2Parser):
|
class Python27Parser(Python2Parser):
|
||||||
|
|
||||||
@@ -221,6 +224,8 @@ class Python27Parser(Python2Parser):
|
|||||||
# FIXME: Put more in this table
|
# FIXME: Put more in this table
|
||||||
self.reduce_check_table = {
|
self.reduce_check_table = {
|
||||||
"ifelsestmt": ifelsestmt,
|
"ifelsestmt": ifelsestmt,
|
||||||
|
"tryelsestmt": tryelsestmt,
|
||||||
|
"tryelsestmtl": tryelsestmt,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.check_reduce["and"] = "AST"
|
self.check_reduce["and"] = "AST"
|
||||||
@@ -250,7 +255,7 @@ class Python27Parser(Python2Parser):
|
|||||||
n = len(tokens)
|
n = len(tokens)
|
||||||
fn = self.reduce_check_table.get(lhs, None)
|
fn = self.reduce_check_table.get(lhs, None)
|
||||||
if fn:
|
if fn:
|
||||||
return fn(self, lhs, n, rule, ast, tokens, first, last)
|
invalid = fn(self, lhs, n, rule, ast, tokens, first, last)
|
||||||
last = min(last, n-1)
|
last = min(last, n-1)
|
||||||
if invalid:
|
if invalid:
|
||||||
return invalid
|
return invalid
|
||||||
|
@@ -7,6 +7,8 @@ def tryelsestmt(self, lhs, n, rule, ast, tokens, first, last):
|
|||||||
# inside the except handler to the end. If that happens
|
# inside the except handler to the end. If that happens
|
||||||
# then this is a "try" with no "else".
|
# then this is a "try" with no "else".
|
||||||
except_handler = ast[3]
|
except_handler = ast[3]
|
||||||
|
if except_handler == "except_handler_else":
|
||||||
|
except_handler = except_handler[0]
|
||||||
if except_handler == "except_handler":
|
if except_handler == "except_handler":
|
||||||
|
|
||||||
come_from = except_handler[-1]
|
come_from = except_handler[-1]
|
||||||
|
Reference in New Issue
Block a user