parse13.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Copyright (c) 2018, 2023 Rocky Bernstein
  2. from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
  3. from uncompyle6.parser import PythonParserSingle
  4. from uncompyle6.parsers.parse14 import Python14Parser
  5. class Python13Parser(Python14Parser):
  6. def p_misc13(self, args):
  7. """
  8. # Nothing here yet, but will need to add LOAD_GLOBALS
  9. """
  10. def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
  11. super(Python13Parser, self).__init__(debug_parser)
  12. self.customized = {}
  13. # def customize_grammar_rules(self, tokens, customize):
  14. # super(Python13Parser, self).customize_grammar_rules(tokens, customize)
  15. # self.remove_rules("""
  16. # whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt
  17. # jb_pop
  18. # POP_BLOCK else_suitel COME_FROM
  19. # """)
  20. # self.check_reduce['doc_junk'] = 'tokens'
  21. # def reduce_is_invalid(self, rule, ast, tokens, first, last):
  22. # invalid = super(Python14Parser,
  23. # self).reduce_is_invalid(rule, ast,
  24. # tokens, first, last)
  25. # if invalid or tokens is None:
  26. # return invalid
  27. # if rule[0] == 'doc_junk':
  28. # return not isinstance(tokens[first].pattr, str)
  29. class Python13ParserSingle(Python13Parser, PythonParserSingle):
  30. pass
  31. if __name__ == "__main__":
  32. # Check grammar
  33. p = Python13Parser()
  34. p.check_grammar()
  35. p.dump_grammar()
  36. # local variables:
  37. # tab-width: 4