Update scanner demo code

This commit is contained in:
rocky
2022-04-17 11:41:19 -04:00
parent f8ae674890
commit c806ef59c6
14 changed files with 117 additions and 77 deletions

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2015-2017, 2021 by Rocky Bernstein
# Copyright (c) 2015-2017, 2021-2022 by Rocky Bernstein
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
#
@@ -280,3 +280,18 @@ class Scanner26(scan.Scanner2):
print(t.format(line_prefix=""))
print()
return tokens, customize
if __name__ == "__main__":
from xdis.version_info import PYTHON_VERSION_TRIPLE, version_tuple_to_str
if PYTHON_VERSION_TRIPLE[:2] == (2, 6):
import inspect
co = inspect.currentframe().f_code # type: ignore
tokens, customize = Scanner26().ingest(co)
for t in tokens:
print(t.format())
pass
else:
print("Need to be Python 2.6 to demo; I am version %s" % version_tuple_to_str())