ptx_parser/unparser/
mod.rs

1pub(crate) mod common;
2pub(crate) mod function;
3pub(crate) mod instruction;
4pub(crate) mod module;
5pub(crate) mod variable;
6
7use crate::lexer::PtxToken;
8
9#[allow(unused_imports)]
10pub(crate) use common::{
11    push_decimal, push_directive, push_identifier, push_opcode, push_register, push_token_from_str,
12};
13
14/// Trait that mirrors [`crate::parser::PtxParser`] but for emitting PTX source
15/// text from the structured representation.
16pub trait PtxUnparser {
17    /// Append the PTX token sequence representing `self` to `tokens`.
18    fn unparse_tokens(&self, tokens: &mut Vec<PtxToken>);
19
20    /// Convenience helper that returns the serialized PTX token stream.
21    fn to_tokens(&self) -> Vec<PtxToken> {
22        let mut tokens = Vec::new();
23        self.unparse_tokens(&mut tokens);
24        tokens
25    }
26}