Skip to content

Commit 92d63ac

Browse files
committed
More 3.0 grammar fixes...
3.0 is such as snowflake
1 parent 79bed34 commit 92d63ac

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

test/bytecode_3.0/03_pop_top.pyc

728 Bytes
Binary file not shown.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# From 3.0.1 __dummy_thread.py
2+
# bug was handling else:
3+
def interrupt_main():
4+
"""Set _interrupt flag to True to have start_new_thread raise
5+
KeyboardInterrupt upon exiting."""
6+
if _main:
7+
raise KeyboardInterrupt
8+
else:
9+
global _interrupt
10+
_interrupt = True
11+
12+
# From 3.0.1 ast.py bug was mangling prototype
13+
# def parse(expr, filename='<unknown>', mode='exec'):
14+
15+
# From 3.0.1 bisect
16+
def bisect_left(a, x, lo=0, hi=None):
17+
while lo:
18+
if a[mid] < x: lo = mid+1
19+
else: hi = mid
20+
return lo

uncompyle6/parsers/parse30.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def p_30(self, args):
2020
2121
# In many ways Python 3.0 code generation is more like Python 2.6 than
2222
# it is 2.7 or 3.1. So we have a number of 2.6ish (and before) rules below
23+
# Specifically POP_TOP is more prevelant since there is no POP_JUMP_IF_...
24+
# instructions
2325
2426
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_froms POP_TOP COME_FROM
2527
@@ -54,6 +56,8 @@ def p_30(self, args):
5456
comp_iter ::= expr expr SET_ADD
5557
comp_iter ::= expr expr LIST_APPEND
5658
59+
jump_forward_else ::= JUMP_FORWARD POP_TOP
60+
5761
# In many ways 3.0 is like 2.6. The below rules in fact are the same or similar.
5862
5963
jmp_true ::= JUMP_IF_TRUE POP_TOP
@@ -63,6 +67,8 @@ def p_30(self, args):
6367
POP_TOP END_FINALLY come_froms
6468
return_if_stmt ::= ret_expr RETURN_END_IF POP_TOP
6569
and ::= expr JUMP_IF_FALSE POP_TOP expr COME_FROM
70+
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt
71+
JUMP_BACK POP_TOP POP_BLOCK COME_FROM_LOOP
6672
"""
6773

6874
def customize_grammar_rules(self, tokens, customize):

0 commit comments

Comments
 (0)