You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
DRY Python3 grammar
This commit is contained in:
@@ -376,9 +376,7 @@ class Python3Parser(PythonParser):
|
|||||||
# Python 3.4+
|
# Python 3.4+
|
||||||
expr ::= LOAD_CLASSDEREF
|
expr ::= LOAD_CLASSDEREF
|
||||||
|
|
||||||
binary_subscr2 ::= expr expr DUP_TOP_TWO BINARY_SUBSCR
|
|
||||||
# Python3 drops slice0..slice3
|
# Python3 drops slice0..slice3
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@@ -10,9 +10,6 @@ from uncompyle6.parsers.parse3 import Python3Parser
|
|||||||
class Python32Parser(Python3Parser):
|
class Python32Parser(Python3Parser):
|
||||||
def p_32to35(self, args):
|
def p_32to35(self, args):
|
||||||
"""
|
"""
|
||||||
# In Python 3.2+, DUP_TOPX is DUP_TOP_TWO
|
|
||||||
binary_subscr2 ::= expr expr DUP_TOP_TWO BINARY_SUBSCR
|
|
||||||
|
|
||||||
# Store locals is only in Python 3.0 to 3.3
|
# Store locals is only in Python 3.0 to 3.3
|
||||||
stmt ::= store_locals
|
stmt ::= store_locals
|
||||||
store_locals ::= LOAD_FAST STORE_LOCALS
|
store_locals ::= LOAD_FAST STORE_LOCALS
|
||||||
|
@@ -19,7 +19,6 @@ class Python33Parser(Python32Parser):
|
|||||||
# actions that want c_stmts_opt at index 1
|
# actions that want c_stmts_opt at index 1
|
||||||
|
|
||||||
iflaststmt ::= testexpr c_stmts_opt33
|
iflaststmt ::= testexpr c_stmts_opt33
|
||||||
iflaststmtl ::= testexpr c_stmts_opt
|
|
||||||
c_stmts_opt33 ::= JUMP_BACK JUMP_ABSOLUTE c_stmts_opt
|
c_stmts_opt33 ::= JUMP_BACK JUMP_ABSOLUTE c_stmts_opt
|
||||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_from
|
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_from
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ class Python34Parser(Python33Parser):
|
|||||||
"""
|
"""
|
||||||
# Python 3.4+ optimizes the trailing two JUMPS away
|
# Python 3.4+ optimizes the trailing two JUMPS away
|
||||||
|
|
||||||
for_block ::= l_stmts
|
|
||||||
|
|
||||||
# Is this 3.4 only?
|
# Is this 3.4 only?
|
||||||
yield_from ::= expr GET_ITER LOAD_CONST YIELD_FROM
|
yield_from ::= expr GET_ITER LOAD_CONST YIELD_FROM
|
||||||
"""
|
"""
|
||||||
|
@@ -45,13 +45,7 @@ class Python35Parser(Python34Parser):
|
|||||||
# Python 3.3+ also has yield from. 3.5 does it
|
# Python 3.3+ also has yield from. 3.5 does it
|
||||||
# differently than 3.3, 3.4
|
# differently than 3.3, 3.4
|
||||||
|
|
||||||
expr ::= yield_from
|
|
||||||
yield_from ::= expr GET_YIELD_FROM_ITER LOAD_CONST YIELD_FROM
|
yield_from ::= expr GET_YIELD_FROM_ITER LOAD_CONST YIELD_FROM
|
||||||
|
|
||||||
# Python 3.4+ has more loop optimization that removes
|
|
||||||
# JUMP_FORWARD in some cases, and hence we also don't
|
|
||||||
# see COME_FROM
|
|
||||||
_ifstmts_jump ::= c_stmts_opt
|
|
||||||
"""
|
"""
|
||||||
class Python35ParserSingle(Python35Parser, PythonParserSingle):
|
class Python35ParserSingle(Python35Parser, PythonParserSingle):
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user