Add triple compare from 3.3 into 3.2

This commit is contained in:
rocky
2017-11-23 13:43:19 -05:00
parent 7548364e8e
commit a94b844988
4 changed files with 7 additions and 2 deletions

Binary file not shown.

View File

@@ -11,6 +11,7 @@ class Python32Parser(Python3Parser):
def p_32to35(self, args):
"""
conditional ::= expr jmp_false expr jump_forward_else expr COME_FROM
cmp_list2 ::= expr COMPARE_OP RETURN_VALUE
# Store locals is only in Python 3.0 to 3.3
stmt ::= store_locals

View File

@@ -15,8 +15,6 @@ class Python33Parser(Python32Parser):
expr ::= yield_from
yield_from ::= expr expr YIELD_FROM
cmp_list2 ::= expr COMPARE_OP RETURN_VALUE
# We do the grammar hackery below for semantics
# actions that want c_stmts_opt at index 1
@@ -33,7 +31,9 @@ class Python33Parser(Python32Parser):
def add_custom_rules(self, tokens, customize):
self.remove_rules("""
# 3.3+ adds POP_BLOCKS
whileTruestmt ::= SETUP_LOOP l_stmts JUMP_ABSOLUTE JUMP_BACK COME_FROM_LOOP
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM_LOOP
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK NOP COME_FROM_LOOP
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK NOP COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK

View File

@@ -141,6 +141,10 @@ class Python35Parser(Python34Parser):
"""
def add_custom_rules(self, tokens, customize):
self.remove_rules("""
# FIXME: should this be in 3.3?
whileTruestmt ::= SETUP_LOOP return_stmts COME_FROM_LOOP
""")
super(Python35Parser, self).add_custom_rules(tokens, customize)
for i, token in enumerate(tokens):
opname = token.kind