Add 3.0 gen_comp_body rule.

This commit is contained in:
rocky
2019-11-11 05:10:54 -05:00
parent 07ec8fa1fb
commit bdc24d7f51
3 changed files with 12 additions and 1 deletions

Binary file not shown.

View File

@@ -18,3 +18,13 @@ def parse_marked_section(fn, i, rawdata, report=1):
j = 1
fn(rawdata[i: j])
return 10
# From 3.0.1 _abcoll.py
# Bug was in genexpr_func which doesn't have a JUMP_BACK but
# in its gen_comp_body, we can use COME_FROM in its place.
# As above omission of JUMPs is a feature of 3.0 that doesn't
# seem to be in later versions (or earlier like 2.6).
def __and__(self, other):
if not isinstance(other, Iterable):
return NotImplemented
return self._from_iterable(value for value in other if value in self)

View File

@@ -119,8 +119,9 @@ class Python30Parser(Python31Parser):
call_stmt ::= expr COME_FROM
_ifstmts_jump30 ::= c_stmts POP_TOP
################################################################################
gen_comp_body ::= expr YIELD_VALUE COME_FROM POP_TOP
################################################################################
for_block ::= l_stmts_opt _come_froms POP_TOP JUMP_BACK
except_handler ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts