Fox some 3.6 async_forelse parsing

This commit is contained in:
rocky
2022-05-05 07:09:39 -04:00
parent f9a1f6fcd9
commit c5efec1e6f
4 changed files with 31 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2016-2020 Rocky Bernstein
# Copyright (c) 2016-2020, 2022 Rocky Bernstein
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -29,13 +29,13 @@ class Python36Parser(Python35Parser):
self.customized = {}
def p_jump_36(self, args):
def p_36_jump(self, args):
"""
# Zero or one COME_FROM
# And/or expressions have this
come_from_opt ::= COME_FROM?
"""
def p_misc_36(self, args):
def p_36_misc(self, args):
"""sstmt ::= sstmt RETURN_LAST
# long except clauses in a loop can sometimes cause a JUMP_BACK to turn into a
@@ -113,6 +113,7 @@ class Python36Parser(Python35Parser):
COME_FROM_LOOP
stmt ::= async_for_stmt36
stmt ::= async_forelse_stmt36
async_forelse_stmt ::= SETUP_LOOP expr
GET_AITER
@@ -126,6 +127,19 @@ class Python36Parser(Python35Parser):
for_block POP_BLOCK
else_suite COME_FROM_LOOP
async_forelse_stmt36 ::= SETUP_LOOP expr
GET_AITER
LOAD_CONST YIELD_FROM SETUP_EXCEPT GET_ANEXT LOAD_CONST
YIELD_FROM
store
POP_BLOCK JUMP_FORWARD COME_FROM_EXCEPT DUP_TOP
LOAD_GLOBAL COMPARE_OP POP_JUMP_IF_TRUE
END_FINALLY COME_FROM
for_block
POP_TOP POP_TOP POP_TOP POP_EXCEPT POP_TOP
POP_BLOCK
else_suite COME_FROM_LOOP
# Adds a COME_FROM_ASYNC_WITH over 3.5
# FIXME: remove corresponding rule for 3.5?
@@ -182,7 +196,7 @@ class Python36Parser(Python35Parser):
# Some of this is duplicated from parse37. Eventually we'll probably rebase from
# that and then we can remove this.
def p_37conditionals(self, args):
def p_36_conditionals(self, args):
"""
expr ::= if_exp37
if_exp37 ::= expr expr jf_cfs expr COME_FROM

View File

@@ -510,7 +510,7 @@ class Python37Parser(Python37BaseParser):
_ifstmts_jump ::= c_stmts_opt JUMP_ABSOLUTE JUMP_FORWARD _come_froms
"""
def p_35on(self, args):
def p_35_on(self, args):
"""
while1elsestmt ::= setup_loop l_stmts JUMP_BACK
@@ -568,7 +568,7 @@ class Python37Parser(Python37BaseParser):
iflaststmt ::= testexpr c_stmts_opt JUMP_FORWARD
"""
def p_37async(self, args):
def p_37_async(self, args):
"""
stmt ::= async_for_stmt37
stmt ::= async_for_stmt
@@ -616,7 +616,7 @@ class Python37Parser(Python37BaseParser):
else_suite COME_FROM_LOOP
"""
def p_37chained(self, args):
def p_37_chained(self, args):
"""
testtrue ::= compare_chained37
testfalse ::= compare_chained37_false
@@ -661,7 +661,7 @@ class Python37Parser(Python37BaseParser):
compare_chained2a_false_37
"""
def p_37conditionals(self, args):
def p_37_conditionals(self, args):
"""
expr ::= if_exp37
if_exp37 ::= expr expr jf_cfs expr COME_FROM
@@ -1195,7 +1195,7 @@ class Python37Parser(Python37BaseParser):
compare_chained2 ::= expr COMPARE_OP come_froms JUMP_FORWARD
"""
def p_37misc(self, args):
def p_37_misc(self, args):
"""
# long except clauses in a loop can sometimes cause a JUMP_BACK to turn into a
# JUMP_FORWARD to a JUMP_BACK. And when this happens there is an additional