2.6 ifelsestmt

This commit is contained in:
rocky 2016-07-01 17:15:00 -04:00
parent 71822bf9b3
commit 4dff02b19c
3 changed files with 11 additions and 2 deletions

Binary file not shown.

View File

@ -9,3 +9,12 @@ def Bastion(object, filter = lambda name: name[:1] != '_'):
if type(attribute) == MethodType:
return attribute
raise AttributeError, name
# Also from 2.6
# The use of the "and" causes to COME_FROMs in the else clause
# ifelsestmt ::= testexpr c_stmts_opt jf_cf_pop else_suite COME_FROM
def loop(select, use_poll=False):
if use_poll and hasattr(select, 'poll'):
poll_fun = 'b'
else:
poll_fun = 'a'

View File

@ -77,7 +77,7 @@ class Python26Parser(Python2Parser):
jb_cf_pop ::= JUMP_BACK come_froms POP_TOP
ja_cf_pop ::= JUMP_ABSOLUTE come_from_pop
jf_cf_pop ::= JUMP_FORWARD come_from_pop
jf_cf_pop ::= JUMP_FORWARD come_froms POP_TOP
jb_bp_come_from ::= JUMP_BACK POP_BLOCK COME_FROM
@ -104,7 +104,7 @@ class Python26Parser(Python2Parser):
break_stmt ::= BREAK_LOOP JUMP_BACK
# Semantic actions want the else to be at position 3
ifelsestmt ::= testexpr c_stmts_opt jf_pop else_suite COME_FROM
ifelsestmt ::= testexpr c_stmts_opt jf_cf_pop else_suite COME_FROM
ifelsestmt ::= testexpr c_stmts_opt filler else_suitel come_froms POP_TOP
# Semantic actions want else_suitel to be at index 3