Python 3.0 if/else handling

This commit is contained in:
rocky
2019-11-10 17:23:33 -05:00
parent 96dcdfd744
commit 04c2240d63
4 changed files with 12 additions and 9 deletions

Binary file not shown.

View File

@@ -0,0 +1,9 @@
# Adapted from 3.0 base64
# Problem was handling if/else which
# needs to be like Python 2.6 (and not like 2.7 or 3.1)
def main(args, f):
"""Small main program"""
if args and args[0] != '-':
func(f, sys.stdout.buffer)
else:
func(sys.stdin.buffer, sys.stdout.buffer)

View File

@@ -1439,15 +1439,6 @@ class Python3Parser(PythonParser):
""",
nop_func
)
if self.version == 3.0:
self.addRule(
"""
tryelsestmtl3 ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
except_handler COME_FROM else_suitel
JUMP_FORWARD come_froms POP_TOP
""",
nop_func
)
custom_ops_processed.add(opname)
elif opname_base in ("UNPACK_EX",):

View File

@@ -47,6 +47,9 @@ class Python30Parser(Python31Parser):
iflaststmtl ::= testexpr c_stmts_opt jb_pop_top
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE COME_FROM POP_TOP
jf_cf_pop ::= JUMP_FORWARD come_froms POP_TOP
ifelsestmt ::= testexpr c_stmts_opt jf_cf_pop else_suite COME_FROM
withasstmt ::= expr setupwithas store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_FINALLY
LOAD_FAST DELETE_FAST WITH_CLEANUP END_FINALLY