heads.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. """
  2. All of the specific kinds of canned parsers for Python 3.8
  3. These are derived from "compile-modes" but we have others that
  4. can be used to parse common part of a larger grammar.
  5. For example:
  6. * a basic-block expression (no branching)
  7. * an unadorned expression (no POP_TOP needed afterwards)
  8. * A non-compound statement
  9. """
  10. from decompyle3.parsers.p38pypy.full import Python38PyPyParser
  11. from decompyle3.parsers.p38pypy.lambda_expr import Python38PyPyLambdaParser
  12. from decompyle3.parsers.parse_heads import ( # FIXME: add; PythonParserSimpleStmt; PythonParserStmt
  13. PythonParserEval,
  14. PythonParserExec,
  15. PythonParserExpr,
  16. PythonParserLambda,
  17. PythonParserSingle,
  18. )
  19. # Make sure to list Python38... classes first so we prefer to inherit methods from that first.
  20. # In particular methods like reduce_is_invalid() need to come from there rather than
  21. # a more generic place.
  22. class Python38PyPyParserEval(Python38PyPyLambdaParser, PythonParserEval):
  23. def __init__(self, debug_parser):
  24. PythonParserEval.__init__(self, debug_parser)
  25. class Python38PyPyParserExec(Python38PyPyParser, PythonParserExec):
  26. def __init__(self, debug_parser):
  27. PythonParserExec.__init__(self, debug_parser)
  28. class Python38PyPyParserExpr(Python38PyPyParser, PythonParserExpr):
  29. def __init__(self, debug_parser):
  30. PythonParserExpr.__init__(self, debug_parser)
  31. # Understand: Python38LambdaParser has to come before PythonParserLambda or we get a
  32. # MRO failure
  33. class Python38PyPyParserLambda(Python38PyPyLambdaParser, PythonParserLambda):
  34. def __init__(self, debug_parser):
  35. PythonParserLambda.__init__(self, debug_parser)
  36. # These classes are here just to get parser doc-strings for the
  37. # various classes inherited properly and start_symbols set properly.
  38. class Python38PyPyParserSingle(Python38PyPyParser, PythonParserSingle):
  39. def __init__(self, debug_parser):
  40. PythonParserSingle.__init__(self, debug_parser)