More 3.0 grammar fixes...

3.0 is such as snowflake
This commit is contained in:
rocky
2018-06-10 05:26:00 -04:00
parent 79bed3419f
commit 92d63ac598
3 changed files with 26 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,20 @@
# From 3.0.1 __dummy_thread.py
# bug was handling else:
def interrupt_main():
"""Set _interrupt flag to True to have start_new_thread raise
KeyboardInterrupt upon exiting."""
if _main:
raise KeyboardInterrupt
else:
global _interrupt
_interrupt = True
# From 3.0.1 ast.py bug was mangling prototype
# def parse(expr, filename='<unknown>', mode='exec'):
# From 3.0.1 bisect
def bisect_left(a, x, lo=0, hi=None):
while lo:
if a[mid] < x: lo = mid+1
else: hi = mid
return lo

View File

@@ -20,6 +20,8 @@ class Python30Parser(Python31Parser):
# In many ways Python 3.0 code generation is more like Python 2.6 than
# it is 2.7 or 3.1. So we have a number of 2.6ish (and before) rules below
# Specifically POP_TOP is more prevelant since there is no POP_JUMP_IF_...
# instructions
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_froms POP_TOP COME_FROM
@@ -54,6 +56,8 @@ class Python30Parser(Python31Parser):
comp_iter ::= expr expr SET_ADD
comp_iter ::= expr expr LIST_APPEND
jump_forward_else ::= JUMP_FORWARD POP_TOP
# In many ways 3.0 is like 2.6. The below rules in fact are the same or similar.
jmp_true ::= JUMP_IF_TRUE POP_TOP
@@ -63,6 +67,8 @@ class Python30Parser(Python31Parser):
POP_TOP END_FINALLY come_froms
return_if_stmt ::= ret_expr RETURN_END_IF POP_TOP
and ::= expr JUMP_IF_FALSE POP_TOP expr COME_FROM
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt
JUMP_BACK POP_TOP POP_BLOCK COME_FROM_LOOP
"""
def customize_grammar_rules(self, tokens, customize):