Add Python 3.0.1 list_comp rule

This commit is contained in:
rocky
2019-11-15 21:32:31 -05:00
parent 47c847644e
commit 4e9d8783d1
2 changed files with 14 additions and 1 deletions

View File

@@ -254,7 +254,7 @@ class Python26Parser(Python2Parser):
POP_TOP jb_pb_come_from
generator_exp ::= LOAD_GENEXPR MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1 COME_FROM
list_if ::= list_if ::= expr jmp_false_then list_iter
list_if ::= expr jmp_false_then list_iter
'''
def p_ret26(self, args):

View File

@@ -75,6 +75,9 @@ class Python30Parser(Python31Parser):
list_comp ::= list_comp_header
LOAD_FAST FOR_ITER store comp_iter
JUMP_BACK
list_comp ::= list_comp_header
LOAD_FAST FOR_ITER store comp_iter
JUMP_BACK _come_froms POP_TOP JUMP_BACK
set_comp_header ::= BUILD_SET_0 DUP_TOP STORE_FAST
set_comp ::= set_comp_header
@@ -86,6 +89,16 @@ class Python30Parser(Python31Parser):
LOAD_FAST FOR_ITER store dict_comp_iter
JUMP_BACK
# From Python 2.6
list_iter ::= list_if JUMP_BACK
list_iter ::= list_if JUMP_BACK _come_froms POP_TOP
lc_body ::= LOAD_NAME expr LIST_APPEND
lc_body ::= LOAD_FAST expr LIST_APPEND
list_if ::= expr jmp_false_then list_iter
#############
dict_comp_iter ::= expr expr ROT_TWO expr STORE_SUBSCR
# JUMP_IF_TRUE POP_TOP as a replacement