More Python 3.0 parse errors

This commit is contained in:
rocky
2018-06-23 13:31:16 -04:00
parent 8d1bd6d5b5
commit bc16cc93d6
3 changed files with 15 additions and 5 deletions

View File

@@ -265,7 +265,7 @@ class Python26Parser(Python2Parser):
kvlist ::= kvlist kv3
# Note: preserve positions 0 2 and 4 for semantic actions
conditional_not ::= expr jmp_true expr jf_cf_pop expr COME_FROM
conditional_not : := expr jmp_true expr jf_cf_pop expr COME_FROM
conditional ::= expr jmp_false expr jf_cf_pop expr come_from_opt
expr ::= conditional_not

View File

@@ -59,6 +59,7 @@ class Python30Parser(Python31Parser):
JUMP_BACK
# JUMP_IF_TRUE POP_TOP as a replacement
comp_if ::= expr jmp_false comp_iter
comp_iter ::= expr expr SET_ADD
comp_iter ::= expr expr LIST_APPEND
@@ -69,12 +70,16 @@ class Python30Parser(Python31Parser):
except_suite_finalize ::= SETUP_FINALLY c_stmts_opt except_var_finalize END_FINALLY
_jump POP_TOP
jump_except ::= JUMP_FORWARD POP_TOP
or ::= expr jmp_false expr jmp_true expr
################################################################################
# In many ways 3.0 is like 2.6. The below rules in fact are the same or similar.
# In many ways 3.0 is like 2.6. One similarity is there is no JUMP_IF_TRUE and
# JUMP_IF_FALSE
# The below rules in fact are the same or similar.
jmp_true ::= JUMP_IF_TRUE POP_TOP
jmp_false ::= JUMP_IF_FALSE POP_TOP
for_block ::= l_stmts_opt _come_froms POP_TOP JUMP_BACK
except_handler ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts

View File

@@ -1170,6 +1170,11 @@ class SourceWalker(GenericASTTraversal, object):
# collection = node[-3]
collections = [node[-3]]
list_ifs = []
if self.version == 3.0 and n != 'list_iter':
# FIXME 3.0 is a snowflake here. We'll need
# special code for this
return
assert n == 'list_iter'
stores = []