Skip to main content

Python Syntax Tree Printer

This project is a Python-based syntax tree printer utility that reads a source code file, guesses the language based on the file extension, and prints the syntax tree using tree-sitter.

Features

  • Supports Rust and Python source files
  • Prints detailed syntax tree nodes
  • Uses Tree-sitter for parsing
  • Syntax highlighting for parse trees
  • Lists all node IDs and their corresponding names for a language

Requirements

  • Python 3.10+
  • pip

Installation

  1. Clone this repository:

    git clone https://github.com/yourusername/python-syntax-tree-printer.git
    cd python-syntax-tree-printer
    
  2. Install the required dependencies:

    pip install .
    

Usage

  1. Run the program with a file path as an argument to print the syntax tree:

    tsutil <file-path>
    
  2. Run the program with the --highlight flag to print the syntax tree with syntax highlighting:

    tsutil <file-path> --highlight
    
  3. Run the program with the --list-ids flag to list all node IDs and their corresponding names for the language:

    tsutil <file-path> --list-ids
    

Example

To print the syntax tree of a Python source file:

tsutil example/simple_addition.py

To print the syntax tree with syntax highlighting:

tsutil example/simple_addition.py --highlight

To list all node IDs and their corresponding names for a Python source file:

tsutil example/simple_addition.py --list-ids

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

Acknowledgements

Metadata

Release files for tsutil-py 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tsutil-py 0.1.0
File Size Uploaded
tsutil_py-0.1.0.tar.gz 2.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tsutil-py 0.1.0
File Interpreter ABI Platform
tsutil_py-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.4 kB

Release files / tsutil_py-0.1.0.tar.gz

Download URL tsutil_py-0.1.0.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
76f9daf3786317a7c03c34825c1e9db5f5225d1e966f4c6b643ae7eb86695909
BLAKE2b-256 checksum
How to use checksums
cd8ba0ef35391cddc110b67268a78688df4c6e93da38c04ad25dbc7c01b8ac22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.16.1 CPython/3.11.5 Linux/5.15.0-91-generic

Release files / tsutil_py-0.1.0-py3-none-any.whl

Download URL tsutil_py-0.1.0-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c05a8a5808b8ca2a76269c228154a4de26e7d8ea44e4ec831a8b13fa676d1c86
BLAKE2b-256 checksum
How to use checksums
20f1829f1b96bf448aa0c659c1e07da18ef68288cd063f12dcbcf1be8bc8da7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.16.1 CPython/3.11.5 Linux/5.15.0-91-generic

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page