1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! PTX (Parallel Thread Execution) parser for NVIDIA GPU assembly language.
//!
//! This library provides a complete parser for PTX assembly code, including:
//! - Lexical analysis (tokenization)
//! - Syntactic parsing into structured types
//! - Unparsing back to PTX source code
//!
//! # Quick Start
//!
//! ```no_run
//! use ptx_parser::{parse_ptx};
//! use ptx_parser::r#type::{Module, ModuleDirective, Instruction};
//!
//! let source = r#"
//! .version 8.5
//! .target sm_90
//! .address_size 64
//!
//! .entry kernel() {
//! add.s32 %r1, %r2, %r3;
//! ret;
//! }
//! "#;
//!
//! let module: Module = parse_ptx(source).expect("Failed to parse PTX");
//! println!("Parsed {} directives", module.directives.len());
//! ```
//!
//! # Type Organization
//!
//! All types are re-exported at `ptx_parser::r#type::*` for easy access:
//!
//! ```rust
//! use ptx_parser::r#type::{
//! Module, // Root AST node
//! Instruction, // Instruction with label/predicate
//! Predicate, // Predicate guard
//! Operand, // Operand types
//! EntryFunctionDirective,
//! FuncFunctionDirective,
//! // ... all other types
//! };
//! ```
//!
//! Instruction variants are under `instruction::`:
//!
//! ```rust
//! use ptx_parser::r#type::instruction::{Inst, add, mov};
//! ```
// Internal modules - not part of public API
// Type definitions - AST nodes (public)
// Pretty-print module - for displaying AST as tree (public)
// Re-export derive macro for the `Spanned` trait so downstream crates can use it.
pub use Spanned;
// Re-export procedural macros for constructor mapping and error handling
pub use ;
// Re-export convenience macros for parser combinators
// Note: map! and try_map! are declarative macros defined in parser/util.rs
// They automatically wrap patterns with cclosure! for cleaner syntax
// Re-export commonly used items for convenience
// Lexer exports
pub use ;
// Parser exports
pub use ;
/// Execute `f` on a dedicated thread with a larger stack so recursive parsers don't overflow.
// Unlexer exports
pub use PtxUnlexer;
// Unparser exports
pub use PtxUnparser;