You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
NT try-middle -> except-handler to match AST
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# From PyPy 2.7 argparse.py
|
# From PyPy 2.7 argparse.py
|
||||||
# PyPY reduces branches as a result of the return statement
|
# PyPY reduces branches as a result of the return statement
|
||||||
# So we need a new rules for try_except and try_middle which we
|
# So we need a new rules for try_except and except_handler which we
|
||||||
# suffix with _pypy, e.g. try_except_pypy, and try_middle_pypy
|
# suffix with _pypy, e.g. try_except_pypy, and except_handler_pypy
|
||||||
def call(self, string):
|
def call(self, string):
|
||||||
try:
|
try:
|
||||||
return open(string, self, self._bufsize)
|
return open(string, self, self._bufsize)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# Tests:
|
# Tests:
|
||||||
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
# try_middle COME_FROM
|
# except_handler COME_FROM
|
||||||
# except_stmt ::= except
|
# except_stmt ::= except
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -10,7 +10,7 @@ except:
|
|||||||
|
|
||||||
# Tests:
|
# Tests:
|
||||||
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
# try_middle COME_FROM
|
# except_handler COME_FROM
|
||||||
# except_stmt ::= except_cond1 except_suite
|
# except_stmt ::= except_cond1 except_suite
|
||||||
# except_suite ::= ...
|
# except_suite ::= ...
|
||||||
|
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
# Tests:
|
# Tests:
|
||||||
# forstmt ::= SETUP_LOOP expr _for store for_block POP_BLOCK COME_FROM
|
# forstmt ::= SETUP_LOOP expr _for store for_block POP_BLOCK COME_FROM
|
||||||
# for_block ::= l_stmts_opt JUMP_BACK
|
# for_block ::= l_stmts_opt JUMP_BACK
|
||||||
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle COME_FROM
|
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK except_handler COME_FROM
|
||||||
# try_middle ::= jmp_abs COME_FROM except_stmts END_FINALLY
|
# except_handler ::= jmp_abs COME_FROM except_stmts END_FINALLY
|
||||||
|
|
||||||
# Had a bug with the end of the except matching the end of the
|
# Had a bug with the end of the except matching the end of the
|
||||||
# for loop.
|
# for loop.
|
||||||
|
@@ -2,12 +2,12 @@
|
|||||||
#
|
#
|
||||||
# tryfinallystmt ::= SETUP_FINALLY suite_stmts POP_BLOCK LOAD_CONST COME_FROM suite_stmts_opt END_FINALLY
|
# tryfinallystmt ::= SETUP_FINALLY suite_stmts POP_BLOCK LOAD_CONST COME_FROM suite_stmts_opt END_FINALLY
|
||||||
# suite_stmts_opt ::= suite_stmts
|
# suite_stmts_opt ::= suite_stmts
|
||||||
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle COME_FROM
|
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK except_handler COME_FROM
|
||||||
# try_middle ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM
|
# except_handler ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM
|
||||||
# except_stmt ::= except_cond1 except_suite
|
# except_stmt ::= except_cond1 except_suite
|
||||||
# except_cond1 ::= DUP_TOP expr COMPARE_OP jmp_false POP_TOP POP_TOP POP_TOP
|
# except_cond1 ::= DUP_TOP expr COMPARE_OP jmp_false POP_TOP POP_TOP POP_TOP
|
||||||
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle COME_FROM
|
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK except_handler COME_FROM
|
||||||
# try_middle ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM
|
# except_handler ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM
|
||||||
# except_cond1 ::= DUP_TOP expr COMPARE_OP jmp_false POP_TOP POP_TOP POP_TOP
|
# except_cond1 ::= DUP_TOP expr COMPARE_OP jmp_false POP_TOP POP_TOP POP_TOP
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
@@ -21,15 +21,15 @@ finally:
|
|||||||
x = 4
|
x = 4
|
||||||
|
|
||||||
# Tests Python3:
|
# Tests Python3:
|
||||||
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle come_froms
|
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK except_handler come_froms
|
||||||
# come_froms ::= COME_FROM COME_FROM
|
# come_froms ::= COME_FROM COME_FROM
|
||||||
# START ::= |- stmts
|
# START ::= |- stmts
|
||||||
# stmts ::= sstmt
|
# stmts ::= sstmt
|
||||||
# sstmt ::= stmt
|
# sstmt ::= stmt
|
||||||
# stmt ::= try_except
|
# stmt ::= try_except
|
||||||
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle come_froms
|
# try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK except_handler come_froms
|
||||||
# come_froms ::= COME_FROM
|
# come_froms ::= COME_FROM
|
||||||
# try_middle ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM
|
# except_handler ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM
|
||||||
# Python2 doesn't have the come_froms (which allows for 3 successive COME_FROMs)
|
# Python2 doesn't have the come_froms (which allows for 3 successive COME_FROMs)
|
||||||
# it does place 2 COME_FROMs at the end of this code.
|
# it does place 2 COME_FROMs at the end of this code.
|
||||||
|
|
||||||
|
@@ -129,24 +129,24 @@ class Python2Parser(PythonParser):
|
|||||||
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK
|
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK
|
||||||
|
|
||||||
# this is nested inside a try_except
|
# this is nested inside a try_except
|
||||||
tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
|
tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
|
||||||
POP_BLOCK LOAD_CONST
|
POP_BLOCK LOAD_CONST
|
||||||
COME_FROM suite_stmts_opt END_FINALLY
|
COME_FROM suite_stmts_opt END_FINALLY
|
||||||
|
|
||||||
# Move to 2.7? 2.6 may use come_froms
|
# Move to 2.7? 2.6 may use come_froms
|
||||||
tryelsestmtc ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmtc ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suitec COME_FROM
|
except_handler else_suitec COME_FROM
|
||||||
|
|
||||||
tryelsestmtl ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmtl ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suitel COME_FROM
|
except_handler else_suitel COME_FROM
|
||||||
|
|
||||||
try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle COME_FROM
|
except_handler COME_FROM
|
||||||
|
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM except_stmts
|
except_handler ::= JUMP_FORWARD COME_FROM except_stmts
|
||||||
END_FINALLY COME_FROM
|
END_FINALLY COME_FROM
|
||||||
try_middle ::= jmp_abs COME_FROM except_stmts
|
except_handler ::= jmp_abs COME_FROM except_stmts
|
||||||
END_FINALLY
|
END_FINALLY
|
||||||
|
|
||||||
except_stmts ::= except_stmt+
|
except_stmts ::= except_stmt+
|
||||||
|
|
||||||
@@ -415,8 +415,8 @@ class Python2Parser(PythonParser):
|
|||||||
# always be the case.
|
# always be the case.
|
||||||
self.add_unique_rules([
|
self.add_unique_rules([
|
||||||
"stmt ::= try_except_pypy",
|
"stmt ::= try_except_pypy",
|
||||||
"try_except_pypy ::= SETUP_EXCEPT suite_stmts_opt try_middle_pypy",
|
"try_except_pypy ::= SETUP_EXCEPT suite_stmts_opt except_handler_pypy",
|
||||||
"try_middle_pypy ::= COME_FROM except_stmts END_FINALLY COME_FROM"
|
"except_handler_pypy ::= COME_FROM except_stmts END_FINALLY COME_FROM"
|
||||||
], customize)
|
], customize)
|
||||||
continue
|
continue
|
||||||
elif opname == 'SETUP_FINALLY':
|
elif opname == 'SETUP_FINALLY':
|
||||||
|
@@ -33,7 +33,7 @@ class Python25Parser(Python26Parser):
|
|||||||
store ::= STORE_NAME
|
store ::= STORE_NAME
|
||||||
|
|
||||||
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suite come_froms
|
except_handler else_suite come_froms
|
||||||
|
|
||||||
# Python 2.6 omits the LOAD_FAST DELETE_FAST below
|
# Python 2.6 omits the LOAD_FAST DELETE_FAST below
|
||||||
# withas is allowed as a "from future" in 2.5
|
# withas is allowed as a "from future" in 2.5
|
||||||
|
@@ -15,43 +15,43 @@ class Python26Parser(Python2Parser):
|
|||||||
|
|
||||||
def p_try_except26(self, args):
|
def p_try_except26(self, args):
|
||||||
"""
|
"""
|
||||||
except_stmt ::= except_cond3 except_suite
|
except_stmt ::= except_cond3 except_suite
|
||||||
except_cond1 ::= DUP_TOP expr COMPARE_OP
|
except_cond1 ::= DUP_TOP expr COMPARE_OP
|
||||||
JUMP_IF_FALSE POP_TOP POP_TOP POP_TOP POP_TOP
|
JUMP_IF_FALSE POP_TOP POP_TOP POP_TOP POP_TOP
|
||||||
except_cond3 ::= DUP_TOP expr COMPARE_OP
|
except_cond3 ::= DUP_TOP expr COMPARE_OP
|
||||||
JUMP_IF_FALSE POP_TOP POP_TOP store POP_TOP
|
JUMP_IF_FALSE POP_TOP POP_TOP store POP_TOP
|
||||||
|
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM except_stmts
|
except_handler ::= JUMP_FORWARD COME_FROM except_stmts
|
||||||
come_from_pop END_FINALLY come_froms
|
come_from_pop END_FINALLY come_froms
|
||||||
|
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY
|
except_handler ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY
|
||||||
come_froms
|
come_froms
|
||||||
|
|
||||||
try_middle ::= jmp_abs COME_FROM except_stmts
|
except_handler ::= jmp_abs COME_FROM except_stmts
|
||||||
POP_TOP END_FINALLY
|
POP_TOP END_FINALLY
|
||||||
|
|
||||||
try_middle ::= jmp_abs COME_FROM except_stmts
|
except_handler ::= jmp_abs COME_FROM except_stmts
|
||||||
END_FINALLY JUMP_FORWARD
|
END_FINALLY JUMP_FORWARD
|
||||||
|
|
||||||
# Sometimes we don't put in COME_FROM to the next statement
|
# Sometimes we don't put in COME_FROM to the next statement
|
||||||
# like we do in 2.7. Perhaps we should?
|
# like we do in 2.7. Perhaps we should?
|
||||||
try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle
|
except_handler
|
||||||
|
|
||||||
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suite COME_FROM
|
except_handler else_suite COME_FROM
|
||||||
|
|
||||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM POP_TOP
|
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD COME_FROM POP_TOP
|
||||||
|
|
||||||
except_suite ::= c_stmts_opt JUMP_FORWARD come_from_pop
|
except_suite ::= c_stmts_opt JUMP_FORWARD come_from_pop
|
||||||
except_suite ::= c_stmts_opt JUMP_FORWARD POP_TOP
|
except_suite ::= c_stmts_opt JUMP_FORWARD POP_TOP
|
||||||
except_suite ::= c_stmts_opt jmp_abs come_from_pop
|
except_suite ::= c_stmts_opt jmp_abs come_from_pop
|
||||||
|
|
||||||
# This is what happens after a jump where
|
# This is what happens after a jump where
|
||||||
# we start a new block. For reasons I don't fully
|
# we start a new block. For reasons I don't fully
|
||||||
# understand, there is also a value on the top of the stack
|
# understand, there is also a value on the top of the stack
|
||||||
come_from_pop ::= COME_FROM POP_TOP
|
come_from_pop ::= COME_FROM POP_TOP
|
||||||
come_froms_pop ::= come_froms POP_TOP
|
come_froms_pop ::= come_froms POP_TOP
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# In contrast to Python 2.7, Python 2.6 has a lot of
|
# In contrast to Python 2.7, Python 2.6 has a lot of
|
||||||
|
@@ -48,7 +48,7 @@ class Python27Parser(Python2Parser):
|
|||||||
COME_FROM_FINALLY suite_stmts_opt END_FINALLY
|
COME_FROM_FINALLY suite_stmts_opt END_FINALLY
|
||||||
|
|
||||||
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suite COME_FROM
|
except_handler else_suite COME_FROM
|
||||||
|
|
||||||
except_stmt ::= except_cond2 except_suite
|
except_stmt ::= except_cond2 except_suite
|
||||||
|
|
||||||
|
@@ -177,7 +177,7 @@ class Python3Parser(PythonParser):
|
|||||||
# COME_FROM targets from the wrong places
|
# COME_FROM targets from the wrong places
|
||||||
|
|
||||||
try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle opt_come_from_except
|
except_handler opt_come_from_except
|
||||||
|
|
||||||
# this is nested inside a try_except
|
# this is nested inside a try_except
|
||||||
tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
|
tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
|
||||||
@@ -185,27 +185,28 @@ class Python3Parser(PythonParser):
|
|||||||
COME_FROM_FINALLY suite_stmts_opt END_FINALLY
|
COME_FROM_FINALLY suite_stmts_opt END_FINALLY
|
||||||
|
|
||||||
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suite come_from_except_clauses
|
except_handler else_suite come_from_except_clauses
|
||||||
|
|
||||||
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suite come_froms
|
except_handler else_suite come_froms
|
||||||
|
|
||||||
tryelsestmtc ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmtc ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suitec come_from_except_clauses
|
except_handler else_suitec come_from_except_clauses
|
||||||
|
|
||||||
tryelsestmtl ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmtl ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suitel come_from_except_clauses
|
except_handler else_suitel come_from_except_clauses
|
||||||
|
|
||||||
try_middle ::= jmp_abs COME_FROM except_stmts
|
except_handler ::= jmp_abs COME_FROM except_stmts
|
||||||
END_FINALLY
|
END_FINALLY
|
||||||
try_middle ::= jmp_abs COME_FROM_EXCEPT except_stmts
|
except_handler ::= jmp_abs COME_FROM_EXCEPT except_stmts
|
||||||
END_FINALLY
|
END_FINALLY
|
||||||
|
|
||||||
# FIXME: remove this
|
# FIXME: remove this
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM except_stmts
|
except_handler ::= JUMP_FORWARD COME_FROM except_stmts
|
||||||
END_FINALLY COME_FROM
|
END_FINALLY COME_FROM
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM except_stmts
|
|
||||||
END_FINALLY COME_FROM_EXCEPT
|
except_handler ::= JUMP_FORWARD COME_FROM except_stmts
|
||||||
|
END_FINALLY COME_FROM_EXCEPT
|
||||||
|
|
||||||
except_stmts ::= except_stmts except_stmt
|
except_stmts ::= except_stmts except_stmt
|
||||||
except_stmts ::= except_stmt
|
except_stmts ::= except_stmt
|
||||||
@@ -267,10 +268,10 @@ class Python3Parser(PythonParser):
|
|||||||
|
|
||||||
def p_misc3(self, args):
|
def p_misc3(self, args):
|
||||||
"""
|
"""
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts
|
except_handler ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts
|
||||||
END_FINALLY COME_FROM
|
END_FINALLY COME_FROM
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts
|
except_handler ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts
|
||||||
END_FINALLY COME_FROM_EXCEPT_CLAUSE
|
END_FINALLY COME_FROM_EXCEPT_CLAUSE
|
||||||
|
|
||||||
for_block ::= l_stmts_opt come_from_loops JUMP_BACK
|
for_block ::= l_stmts_opt come_from_loops JUMP_BACK
|
||||||
for_block ::= l_stmts
|
for_block ::= l_stmts
|
||||||
|
@@ -29,17 +29,17 @@ class Python32Parser(Python3Parser):
|
|||||||
# jump_excepts. But in 3.3 we need them added
|
# jump_excepts. But in 3.3 we need them added
|
||||||
|
|
||||||
try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle
|
except_handler
|
||||||
jump_excepts come_from_except_clauses
|
jump_excepts come_from_except_clauses
|
||||||
|
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts
|
except_handler ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts
|
||||||
END_FINALLY
|
END_FINALLY
|
||||||
|
|
||||||
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle else_suite
|
except_handler else_suite
|
||||||
jump_excepts come_from_except_clauses
|
jump_excepts come_from_except_clauses
|
||||||
|
|
||||||
jump_excepts ::= jump_except+
|
jump_excepts ::= jump_except+
|
||||||
|
|
||||||
# Python 3.2+ has more loop optimization that removes
|
# Python 3.2+ has more loop optimization that removes
|
||||||
# JUMP_FORWARD in some cases, and hence we also don't
|
# JUMP_FORWARD in some cases, and hence we also don't
|
||||||
@@ -65,11 +65,11 @@ class Python32Parser(Python3Parser):
|
|||||||
|
|
||||||
def add_custom_rules(self, tokens, customize):
|
def add_custom_rules(self, tokens, customize):
|
||||||
self.remove_rules("""
|
self.remove_rules("""
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM
|
except_handler ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM_EXCEPT
|
except_handler ::= JUMP_FORWARD COME_FROM except_stmts END_FINALLY COME_FROM_EXCEPT
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts END_FINALLY COME_FROM_EXCEPT_CLAUSE
|
except_handler ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts END_FINALLY COME_FROM_EXCEPT_CLAUSE
|
||||||
try_middle ::= jmp_abs COME_FROM except_stmts END_FINALLY
|
except_handler ::= jmp_abs COME_FROM except_stmts END_FINALLY
|
||||||
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK try_middle else_suite come_from_except_clauses
|
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK except_handler else_suite come_from_except_clauses
|
||||||
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP COME_FROM_LOOP
|
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP COME_FROM_LOOP
|
||||||
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP COME_FROM_LOOP
|
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP COME_FROM_LOOP
|
||||||
""")
|
""")
|
||||||
|
@@ -22,7 +22,7 @@ class Python33Parser(Python32Parser):
|
|||||||
# jump_excepts. But in 3.3 we need them added
|
# jump_excepts. But in 3.3 we need them added
|
||||||
|
|
||||||
try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
try_except ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||||
try_middle
|
except_handler
|
||||||
jump_excepts come_from_except_clauses
|
jump_excepts come_from_except_clauses
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@@ -65,14 +65,14 @@ class Python36Parser(Python35Parser):
|
|||||||
# In 3.6+, A sequence of statements ending in a RETURN can cause
|
# In 3.6+, A sequence of statements ending in a RETURN can cause
|
||||||
# JUMP_FORWARD END_FINALLY to be omitted from try middle
|
# JUMP_FORWARD END_FINALLY to be omitted from try middle
|
||||||
|
|
||||||
except_return ::= POP_TOP POP_TOP POP_TOP return_stmts
|
except_return ::= POP_TOP POP_TOP POP_TOP return_stmts
|
||||||
try_middle ::= JUMP_FORWARD COME_FROM_EXCEPT except_return
|
except_handler ::= JUMP_FORWARD COME_FROM_EXCEPT except_return
|
||||||
|
|
||||||
# Try middle following a return_stmts
|
# Try middle following a return_stmts
|
||||||
try_middle36 ::= COME_FROM_EXCEPT except_stmts END_FINALLY
|
except_handler36 ::= COME_FROM_EXCEPT except_stmts END_FINALLY
|
||||||
|
|
||||||
stmt ::= try_except36
|
stmt ::= try_except36
|
||||||
try_except36 ::= SETUP_EXCEPT return_stmts try_middle36 opt_come_from_except
|
try_except36 ::= SETUP_EXCEPT return_stmts except_handler36 opt_come_from_except
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def add_custom_rules(self, tokens, customize):
|
def add_custom_rules(self, tokens, customize):
|
||||||
|
Reference in New Issue
Block a user