From 6e2a99338b66791734b01c7c5f127661e0790c42 Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Mon, 21 Apr 2025 13:12:40 -0500 Subject: [PATCH] eager2 complicated --- rush_macro/src/lib.rs | 25 +++++++++++++++++++++++++ tests/instruction_test.rs | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/rush_macro/src/lib.rs b/rush_macro/src/lib.rs index 8a5fc50..6bd2848 100644 --- a/rush_macro/src/lib.rs +++ b/rush_macro/src/lib.rs @@ -45,6 +45,31 @@ pub fn run_instruction(input: proc_macro::TokenStream) -> proc_macro::TokenStrea quote! { #f }.into() } +#[proc_macro] +pub fn instruction_list(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + // Convert to proc_macro2::TokenStream for better iteration + let input2: proc_macro2::TokenStream = input.clone().into(); + + println!("Token stream analysis:"); + for token in input2.into_iter() { + match token { + proc_macro2::TokenTree::Group(group) => println!( + "Group: delimiter={:?}, tokens={}", + group.delimiter(), + group.stream() + ), + proc_macro2::TokenTree::Ident(ident) => println!("Identifier: {}", ident), + proc_macro2::TokenTree::Punct(punct) => println!( + "Punctuation: {} (spacing={:?})", + punct.as_char(), + punct.spacing() + ), + proc_macro2::TokenTree::Literal(lit) => println!("Literal: {}", lit), + } + } + input +} + #[cfg(test)] mod tests { #[test] diff --git a/tests/instruction_test.rs b/tests/instruction_test.rs index 68d5083..5d7b70e 100644 --- a/tests/instruction_test.rs +++ b/tests/instruction_test.rs @@ -1,5 +1,5 @@ use rush::push::state::EMPTY_STATE; -use rush_macro::run_instruction; +use rush_macro::{instruction_list, run_instruction}; fn iadd(x: i128, y: i128) -> Option { Some(x + y)