scanner21.py 887 B

123456789101112131415161718192021222324252627
  1. # Copyright (c) 2016-2018, 2021 by Rocky Bernstein
  2. """
  3. Python 2.1 bytecode massaging.
  4. This massages tokenized 2.1 bytecode to make it more amenable for
  5. grammar parsing.
  6. """
  7. import uncompyle6.scanners.scanner22 as scan
  8. # from uncompyle6.scanners.scanner26 import ingest as ingest26
  9. # bytecode verification, verify(), uses JUMP_OPs from here
  10. from xdis.opcodes import opcode_21
  11. JUMP_OPS = opcode_21.JUMP_OPS
  12. # We base this off of 2.2 instead of the other way around
  13. # because we cleaned things up this way.
  14. # The history is that 2.7 support is the cleanest,
  15. # then from that we got 2.6 and so on.
  16. class Scanner21(scan.Scanner22):
  17. def __init__(self, show_asm=False):
  18. scan.Scanner22.__init__(self, show_asm)
  19. self.opc = opcode_21
  20. self.opname = opcode_21.opname
  21. self.version = (2, 1)
  22. self.genexpr_name = '<generator expression>'
  23. return