| Crates.io | ptx-90-parser |
| lib.rs | ptx-90-parser |
| version | 0.4.4 |
| created_at | 2025-10-24 15:26:10.212091+00 |
| updated_at | 2025-11-28 22:57:08.255951+00 |
| description | Parse NVIDIA PTX 9.0 assembly into a structured AST and explore modules via a CLI. |
| homepage | https://github.com/jialunzhang-psu/ptx-90-parser |
| repository | https://github.com/jialunzhang-psu/ptx-90-parser |
| max_upload_size | |
| id | 1898597 |
| size | 9,837,078 |
There is already a crate named ptx-parser on crates.io, but it has not been
updated for 2 years and does not support PTX 9.0. This crate, ptx-90-parser,
parses NVIDIA PTX 9.0 assembly source into a structured abstract syntax tree. It
also ships with a small companion CLI that prints module summaries and
optionally emits a tree representation of the parsed PTX.
crates/parser-gen/ptx_syntax.ptx-parser-bin) that reports module statistics and outputs a tree view.Add the crate to your project:
cargo add ptx-parser
Parse a PTX module from source text:
use ptx_parser::parse;
fn main() -> Result<(), ptx_parser::PtxParseError> {
let module = parse(
r#"
.version 7.8
.target sm_90
.entry add(.param .u64 a) { ret; }
"#,
)?;
println!("directives: {}", module.directives.len());
Ok(())
}
Refer to the items exported from ptx_parser::type for the full AST shape.
cargo run --bin ptx-parser-bin -- --input ./examples/module.ptx
Options:
--input (-i): path to the PTX file to parse (required)--output (-o): optional path for writing the textual tree representationExample:
ptx-parser-bin --input kernel.ptx --output kernel.tree
This project is distributed under the terms of the MIT license. See LICENSE for details.