From d4be647bce8c544105f9d0bda738c0c26cd2ea38 Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 19 Apr 2017 05:08:48 -0400 Subject: [PATCH] 3.5 ifelsestmtl grammar bug. Fixes #108 --- test/bytecode_3.5/03_while-if-break.pyc | Bin 271 -> 310 bytes test/simple_source/bug35/03_while-if-break.py | 7 +++++++ uncompyle6/parsers/parse3.py | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/bytecode_3.5/03_while-if-break.pyc b/test/bytecode_3.5/03_while-if-break.pyc index f7a2f48d0bf801bdd063bcd0410dadafc0f62d62..5f971ce9bfeaec92881b02ec5bb66974c74d1201 100644 GIT binary patch delta 94 zcmeBY+Q!5s#>>m~N#lEjI^#qx7e>m)ysRi<0mDQt7e={>{<1tN3=F}VOnxs}85kHQP7mkd0MZPM%#1vY KjEs|+7)=0UstR`i diff --git a/test/simple_source/bug35/03_while-if-break.py b/test/simple_source/bug35/03_while-if-break.py index d520ca7d..21e3ed1b 100644 --- a/test/simple_source/bug35/03_while-if-break.py +++ b/test/simple_source/bug35/03_while-if-break.py @@ -5,3 +5,10 @@ def display_date(loop): if loop.time(): break x = 5 + + # Another loop to test 3.5 ifelsestmtl grammar rule + while loop: + if x: + True + else: + True diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 5c022056..dc534c57 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -165,7 +165,9 @@ class Python3Parser(PythonParser): ifelsestmtr ::= testexpr return_if_stmts return_stmts ifelsestmtl ::= testexpr c_stmts_opt JUMP_BACK else_suitel - ifelsestmtl ::= testexpr c_stmts_opt COME_FROM JUMP_BACK else_suitel + ifelsestmtl ::= testexpr c_stmts_opt cf_jump_back else_suitel + + cf_jump_back ::= COME_FROM JUMP_BACK # FIXME: this feels like a hack. Is it just 1 or two # COME_FROMs? the parsed tree for this and even with just the