Fix Python 1.5- bug in handling unpack list

This commit is contained in:
rocky
2018-06-04 10:32:55 -04:00
parent 7fd21aa227
commit 096563cf91
8 changed files with 50 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ class Python14Parser(Python15Parser):
# SET_FUNC_ARGS, and RESERVE_FAST
# FIXME: should check that this indeed around __doc__
# Possibly not strictly needed
stmt ::= doc_junk
doc_junk ::= LOAD_CONST POP_TOP
@@ -35,6 +36,26 @@ class Python14Parser(Python15Parser):
super(Python14Parser, self).__init__(debug_parser)
self.customized = {}
def customize_grammar_rules(self, tokens, customize):
super(Python14Parser, self).customize_grammar_rules(tokens, customize)
self.remove_rules("""
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt
jb_pop
POP_BLOCK else_suitel COME_FROM
""")
self.check_reduce['doc_junk'] = 'tokens'
def reduce_is_invalid(self, rule, ast, tokens, first, last):
invalid = super(Python14Parser,
self).reduce_is_invalid(rule, ast,
tokens, first, last)
if invalid or tokens is None:
return invalid
if rule[0] == 'doc_junk':
return not isinstance(tokens[first].pattr, str)
class Python14ParserSingle(Python14Parser, PythonParserSingle):
pass