2020-05-08 09:59:20 +00:00
|
|
|
# Copyright (c) 2016-2017, 2020 Rocky Bernstein
|
2016-08-13 11:08:48 +00:00
|
|
|
# Copyright (c) 2000-2002 by hartmut Goebel <hartmut@goebel.noris.de>
|
|
|
|
|
|
|
|
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
|
|
|
from uncompyle6.parser import PythonParserSingle
|
|
|
|
from uncompyle6.parsers.parse23 import Python23Parser
|
|
|
|
|
|
|
|
class Python22Parser(Python23Parser):
|
|
|
|
|
|
|
|
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
|
2020-05-08 09:59:20 +00:00
|
|
|
super(Python22Parser, self).__init__(debug_parser)
|
2016-08-13 11:08:48 +00:00
|
|
|
self.customized = {}
|
|
|
|
|
|
|
|
def p_misc22(self, args):
|
|
|
|
'''
|
2017-12-12 17:41:44 +00:00
|
|
|
for_iter ::= LOAD_CONST FOR_LOOP
|
2016-10-08 23:51:17 +00:00
|
|
|
list_iter ::= list_if JUMP_FORWARD
|
|
|
|
COME_FROM POP_TOP COME_FROM
|
2017-12-12 17:41:44 +00:00
|
|
|
list_for ::= expr for_iter store list_iter CONTINUE JUMP_FORWARD
|
2016-10-08 23:51:17 +00:00
|
|
|
COME_FROM POP_TOP COME_FROM
|
2018-03-05 17:25:31 +00:00
|
|
|
|
|
|
|
# Some versions of Python 2.2 have been found to generate
|
|
|
|
# PRINT_ITEM_CONT for PRINT_ITEM
|
|
|
|
print_items_stmt ::= expr PRINT_ITEM_CONT print_items_opt
|
2016-08-13 11:08:48 +00:00
|
|
|
'''
|
|
|
|
|
2017-12-13 22:25:19 +00:00
|
|
|
def customize_grammar_rules(self, tokens, customize):
|
|
|
|
super(Python22Parser, self).customize_grammar_rules(tokens, customize)
|
2017-11-26 12:13:04 +00:00
|
|
|
self.remove_rules("""
|
|
|
|
kvlist ::= kvlist kv2
|
|
|
|
""")
|
|
|
|
|
2016-08-13 11:08:48 +00:00
|
|
|
class Python22ParserSingle(Python23Parser, PythonParserSingle):
|
|
|
|
pass
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
# Check grammar
|
|
|
|
p = Python22Parser()
|
2017-10-10 19:11:08 +00:00
|
|
|
p.check_grammar()
|
|
|
|
p.dump_grammar()
|
2016-08-13 11:08:48 +00:00
|
|
|
|
|
|
|
# local variables:
|
|
|
|
# tab-width: 4
|