You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Annotation counts have changed. EXTENDED_ARGS adjustment in instructions have been corrected.
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
# Copyright (c) 2016, 2024 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
|
|
stmt ::= genexpr_func
|
|
"""
|
|
|
|
def customize_grammar_rules(self, tokens, customize):
|
|
self.remove_rules(
|
|
"""
|
|
# 3.3+ adds POP_BLOCKS
|
|
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP COME_FROM_LOOP
|
|
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP COME_FROM_LOOP
|
|
"""
|
|
)
|
|
super(Python33Parser, self).customize_grammar_rules(tokens, customize)
|
|
|
|
# FIXME: move 3.3 stuff out of parse3.py and put it here.
|
|
# for i, token in enumerate(tokens):
|
|
# opname = token.kind
|
|
# opname_base = opname[: opname.rfind("_")]
|
|
|
|
return
|
|
|
|
|
|
class Python33ParserSingle(Python33Parser, PythonParserSingle):
|
|
pass
|