Python 2.3 list comprehensions

This commit is contained in:
rocky
2016-07-09 17:58:28 -04:00
parent 65b9ecee31
commit b44c566a9f
6 changed files with 25 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -10,6 +10,22 @@
# Python 3 grammar includes:
# listcomp ::= LOAD_LISTCOMP LOAD_CONST MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1
[ i for i in (1, 2, 3, 4) ]
[ i+1 for i in (1, 2, 3, 4) ]
[ i * i for i in range(4) ]
# Add line spacing to assist in seeing which parts go where
# in assembly and code
[ i
for
i in
(1, 2, 3, 4)
]
[ i+1
for
i in
(1, 2, 3, 4)
]
[ i * i
for
i in
range(4) ]

View File

@@ -20,6 +20,12 @@ class Python23Parser(Python24Parser):
COME_FROM POP_TOP POP_BLOCK COME_FROM
list_compr ::= BUILD_LIST_0 DUP_TOP LOAD_ATTR designator list_iter del_stmt
list_for ::= expr _for designator list_iter JUMP_BACK come_froms POP_TOP JUMP_BACK
lc_body ::= LOAD_NAME expr CALL_FUNCTION_1 POP_TOP
lc_body ::= LOAD_FAST expr CALL_FUNCTION_1 POP_TOP
lc_body ::= LOAD_NAME expr LIST_APPEND
lc_body ::= LOAD_FAST expr LIST_APPEND
'''
class Python23ParserSingle(Python23Parser, PythonParserSingle):