Skip to content

Commit fef0567

Browse files
committed
Some Python 3.4 grammar rules apply to Python 3.3
1 parent 41f360e commit fef0567

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

uncompyle6/parsers/parse33.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,21 @@ class Python33Parser(Python32Parser):
1212
def p_33on(self, args):
1313
"""
1414
# Python 3.3+ adds yield from.
15-
expr ::= yield_from
16-
yield_from ::= expr expr YIELD_FROM
15+
expr ::= yield_from
16+
yield_from ::= expr expr YIELD_FROM
17+
18+
# We do the grammar hackery below for semantics
19+
# actions that want c_stmts_opt at index 1
20+
21+
iflaststmt ::= testexpr c_stmts_opt33
22+
iflaststmtl ::= testexpr c_stmts_opt
23+
c_stmts_opt33 ::= JUMP_BACK JUMP_ABSOLUTE c_stmts_opt
24+
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_from
25+
26+
# Python 3.3+ has more loop optimization that removes
27+
# JUMP_FORWARD in some cases, and hence we also don't
28+
# see COME_FROM
29+
_ifstmts_jump ::= c_stmts_opt
1730
"""
1831

1932
class Python33ParserSingle(Python33Parser, PythonParserSingle):

uncompyle6/parsers/parse34.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,12 @@ def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
1515

1616
def p_misc34(self, args):
1717
"""
18-
# Python 3.5+ optimizes the trailing two JUMPS away
18+
# Python 3.4+ optimizes the trailing two JUMPS away
1919
2020
for_block ::= l_stmts
2121
22-
iflaststmtl ::= testexpr c_stmts_opt
23-
24-
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_from
25-
26-
# We do the grammar hackery below for semantics
27-
# actions that want c_stmts_opt at index 1
28-
iflaststmt ::= testexpr c_stmts_opt34
29-
c_stmts_opt34 ::= JUMP_BACK JUMP_ABSOLUTE c_stmts_opt
30-
3122
# Is this 3.4 only?
3223
yield_from ::= expr GET_ITER LOAD_CONST YIELD_FROM
33-
34-
# Python 3.4+ has more loop optimization that removes
35-
# JUMP_FORWARD in some cases, and hence we also don't
36-
# see COME_FROM
37-
_ifstmts_jump ::= c_stmts_opt
3824
"""
3925
class Python34ParserSingle(Python34Parser, PythonParserSingle):
4026
pass

0 commit comments

Comments
 (0)