mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
30 lines
876 B
Python
30 lines
876 B
Python
# Copyright 2006 Google, Inc. All Rights Reserved.
|
|
# Licensed to PSF under a Contributor Agreement.
|
|
|
|
"""
|
|
Python parse tree definitions.
|
|
|
|
This is a very concrete parse tree; we need to keep every token and
|
|
even the comments and whitespace between tokens.
|
|
|
|
There's also a pattern matching implementation here.
|
|
"""
|
|
|
|
__author__ = "Guido van Rossum <guido@python.org>"
|
|
|
|
import sys
|
|
from io import StringIO
|
|
|
|
HUGE = 0x7FFFFFFF # maximum repeat count, default max
|
|
|
|
_type_reprs = {}
|
|
def type_repr(type_num):
|
|
global _type_reprs
|
|
if not _type_reprs:
|
|
from .pygram import python_symbols
|
|
# printing tokens is possible but not as useful
|
|
# from .pgen2 import token // token.__dict__.items():
|
|
for name, val in python_symbols.__dict__.items():
|
|
if type(val) == int: _type_reprs[val] = name
|
|
return _type_reprs.setdefault(type_num, type_num)
|