You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Some Python 3.4 grammar rules apply to Python 3.3
This commit is contained in:
@@ -14,6 +14,19 @@ class Python33Parser(Python32Parser):
|
|||||||
# Python 3.3+ adds yield from.
|
# Python 3.3+ adds yield from.
|
||||||
expr ::= yield_from
|
expr ::= yield_from
|
||||||
yield_from ::= expr expr YIELD_FROM
|
yield_from ::= expr expr YIELD_FROM
|
||||||
|
|
||||||
|
# We do the grammar hackery below for semantics
|
||||||
|
# actions that want c_stmts_opt at index 1
|
||||||
|
|
||||||
|
iflaststmt ::= testexpr c_stmts_opt33
|
||||||
|
iflaststmtl ::= testexpr c_stmts_opt
|
||||||
|
c_stmts_opt33 ::= JUMP_BACK JUMP_ABSOLUTE c_stmts_opt
|
||||||
|
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_from
|
||||||
|
|
||||||
|
# Python 3.3+ 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 Python33ParserSingle(Python33Parser, PythonParserSingle):
|
class Python33ParserSingle(Python33Parser, PythonParserSingle):
|
||||||
|
@@ -15,26 +15,12 @@ class Python34Parser(Python33Parser):
|
|||||||
|
|
||||||
def p_misc34(self, args):
|
def p_misc34(self, args):
|
||||||
"""
|
"""
|
||||||
# Python 3.5+ optimizes the trailing two JUMPS away
|
# Python 3.4+ optimizes the trailing two JUMPS away
|
||||||
|
|
||||||
for_block ::= l_stmts
|
for_block ::= l_stmts
|
||||||
|
|
||||||
iflaststmtl ::= testexpr c_stmts_opt
|
|
||||||
|
|
||||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_from
|
|
||||||
|
|
||||||
# We do the grammar hackery below for semantics
|
|
||||||
# actions that want c_stmts_opt at index 1
|
|
||||||
iflaststmt ::= testexpr c_stmts_opt34
|
|
||||||
c_stmts_opt34 ::= JUMP_BACK JUMP_ABSOLUTE c_stmts_opt
|
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
# 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 Python34ParserSingle(Python34Parser, PythonParserSingle):
|
class Python34ParserSingle(Python34Parser, PythonParserSingle):
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user