Pure Python parser for mangled itanium symbols
Project description
Itanium Demangler
The Python Itanium Demangler is a pure Python parser for the Itanium C++ ABI symbol mangling language. Note that MSVC mangling language is not supported.
This demangler generates an abstract syntax tree from mangled symbols, which can be used for directly extracting type information, as opposed to having to interpret the C++ source code corresponding to the demangled symbol
There is also a built-in AST stringifier, so the demangler can be used as a replacement for c++filt
or for formatting backtraces.
Requirements
The demangler runs on Python 2.7 and 3.3+ and has no dependencies.
Installation
Installing via PyPI:
pip install itanium_demangler
Using a local repository for development:
git clone https://github.com/whitequark/python-itanium_demangler
cd python-itanium_demangler
python setup.py develop --user
Usage
from itanium_demangler import parse as demangle
ast = demangle("_ZN5boost6chrono24process_system_cpu_clock3nowEv")
print(repr(ast))
# <FuncNode func <Node qual_name (<Node name 'boost'>, <Node name 'chrono'>, <Node name 'process_system_cpu_clock'>, <Node name 'now'>)> (<Node builtin 'void'>,) None>
print(ast)
# boost::chrono::process_system_cpu_clock::now()
Future considerations
A similar (i.e. also parsing to an AST) implementation of a demangler for the MSVC mangling language would be useful to have.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file itanium_demangler-1.1-py3-none-any.whl
.
File metadata
- Download URL: itanium_demangler-1.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bc2ba4d2f2e3e3b8aa201e4384433fd09a57f512a7717ca3849f93ee34f8189 |
|
MD5 | 07fce95a59a5f5d05e1c1b9212e3e6fc |
|
BLAKE2b-256 | 780dfba3dcefcfcbc9da4e97e55427a5a739e920430ac53d770d98b7a5203500 |