parse21.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright (c) 2016-2017, 2020 Rocky Bernstein
  2. # Copyright (c) 2000-2002 by hartmut Goebel <hartmut@goebel.noris.de>
  3. from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
  4. from uncompyle6.parser import PythonParserSingle
  5. from uncompyle6.parsers.parse22 import Python22Parser
  6. class Python21Parser(Python22Parser):
  7. def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
  8. super(Python21Parser, self).__init__(debug_parser)
  9. self.customized = {}
  10. def p_forstmt21(self, args):
  11. """
  12. for ::= SETUP_LOOP expr for_iter store
  13. returns
  14. POP_BLOCK COME_FROM
  15. for ::= SETUP_LOOP expr for_iter store
  16. l_stmts_opt _jump_back
  17. POP_BLOCK COME_FROM
  18. """
  19. def p_import21(self, args):
  20. '''
  21. alias ::= IMPORT_NAME_CONT store
  22. '''
  23. class Python21ParserSingle(Python22Parser, PythonParserSingle):
  24. pass
  25. if __name__ == '__main__':
  26. # Check grammar
  27. p = Python21Parser()
  28. p.check_grammar()
  29. p.dump_grammar()
  30. # local variables:
  31. # tab-width: 4