Files
python-uncompyle6/uncompyle6/parsers/parse33.py
2017-11-22 06:25:52 -05:00

39 lines
1.2 KiB
Python

# Copyright (c) 2016 Rocky Bernstein
"""
spark grammar differences over Python 3.2 for Python 3.3.
"""
from uncompyle6.parser import PythonParserSingle
from uncompyle6.parsers.parse32 import Python32Parser
class Python33Parser(Python32Parser):
def p_33on(self, args):
"""
# Python 3.3+ adds yield from.
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
whileTruestmt ::= SETUP_LOOP l_stmts JUMP_ABSOLUTE
JUMP_BACK COME_FROM_LOOP
# Python 3.5+ has jump optimization to remove the redundant
# jump_excepts. But in 3.3 we need them added
tryelsestmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
try_middle else_suite
jump_excepts come_from_except_clauses
trystmt ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
try_middle
jump_excepts come_from_except_clauses
jump_excepts ::= jump_except+
"""
class Python33ParserSingle(Python33Parser, PythonParserSingle):
pass