You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
More specific 2.7 dictcomp and setcomp rules
This commit is contained in:
@@ -386,14 +386,20 @@ class Python2Parser(PythonParser):
|
|||||||
('expr '*v, opname))],
|
('expr '*v, opname))],
|
||||||
customize)
|
customize)
|
||||||
if self.version >= 2.7:
|
if self.version >= 2.7:
|
||||||
self.add_unique_rules([
|
if i > 0:
|
||||||
('setcomp ::= %s load_closure LOAD_SETCOMP %s expr'
|
prev_tok = tokens[i-1]
|
||||||
' GET_ITER CALL_FUNCTION_1' %
|
if prev_tok == 'LOAD_DICTCOMP':
|
||||||
('expr '*v, opname)),
|
self.add_unique_rules([
|
||||||
('dictcomp ::= %s load_closure LOAD_DICTCOMP %s expr'
|
('dictcomp ::= %s load_closure LOAD_DICTCOMP %s expr'
|
||||||
' GET_ITER CALL_FUNCTION_1' %
|
' GET_ITER CALL_FUNCTION_1' %
|
||||||
('expr '*v, opname))],
|
('expr '*v, opname))], customize)
|
||||||
customize)
|
elif prev_tok == 'LOAD_SETCOMP':
|
||||||
|
self.add_unique_rules([
|
||||||
|
('setcomp ::= %s load_closure LOAD_SETCOMP %s expr'
|
||||||
|
' GET_ITER CALL_FUNCTION_1' %
|
||||||
|
('expr '*v, opname))
|
||||||
|
], customize)
|
||||||
|
pass
|
||||||
pass
|
pass
|
||||||
continue
|
continue
|
||||||
elif opname == 'SETUP_EXCEPT':
|
elif opname == 'SETUP_EXCEPT':
|
||||||
|
@@ -123,6 +123,7 @@ class Python27Parser(Python2Parser):
|
|||||||
self.remove_rules("""
|
self.remove_rules("""
|
||||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
|
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
|
||||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
|
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
|
||||||
|
tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM suite_stmts_opt END_FINALLY
|
||||||
""")
|
""")
|
||||||
super(Python27Parser, self).add_custom_rules(tokens, customize)
|
super(Python27Parser, self).add_custom_rules(tokens, customize)
|
||||||
self.check_reduce['and'] = 'AST'
|
self.check_reduce['and'] = 'AST'
|
||||||
|
Reference in New Issue
Block a user