internal expansion failed, manually define functions in a list time
This commit is contained in:
parent
9d017eb6ab
commit
f3ff9fd684
@ -4,9 +4,6 @@ use syn::parse_macro_input;
|
|||||||
|
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
/// This macro kinda goes super crazy mode
|
|
||||||
/// Here's how to use the macro:
|
|
||||||
///
|
|
||||||
/// `run_instruction!(function_name, output_stack, push state, any amount of
|
/// `run_instruction!(function_name, output_stack, push state, any amount of
|
||||||
/// comma separated stacks by name ; (the semicolon instructs use whether the instruction
|
/// comma separated stacks by name ; (the semicolon instructs use whether the instruction
|
||||||
/// has multiple outputs. If ; passed, assumes multiple, without assumes just one output))`
|
/// has multiple outputs. If ; passed, assumes multiple, without assumes just one output))`
|
||||||
@ -45,31 +42,6 @@ pub fn run_instruction(input: proc_macro::TokenStream) -> proc_macro::TokenStrea
|
|||||||
quote! { #f }.into()
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
//! This file implements the proc macro implementation for creating a list of instructions
|
|
||||||
//! from a set of passed function declarations.
|
|
@ -1,7 +1,6 @@
|
|||||||
use syn::parse::{Parse, ParseStream};
|
use syn::parse::{Parse, ParseStream};
|
||||||
|
|
||||||
pub mod instruction;
|
pub mod instruction;
|
||||||
pub mod instructionlist;
|
|
||||||
|
|
||||||
fn parse_zero_or_more<T: Parse>(input: ParseStream) -> Vec<T> {
|
fn parse_zero_or_more<T: Parse>(input: ParseStream) -> Vec<T> {
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use crate::instructions::*;
|
|
||||||
use crate::push::interpreter::interpret_program;
|
use crate::push::interpreter::interpret_program;
|
||||||
use crate::push::state::EMPTY_STATE;
|
use crate::push::state::EMPTY_STATE;
|
||||||
|
|
||||||
@ -9,10 +8,4 @@ fn main() {
|
|||||||
// These need to stay so linter doesn't go crazy.
|
// These need to stay so linter doesn't go crazy.
|
||||||
let mut empty_state = EMPTY_STATE;
|
let mut empty_state = EMPTY_STATE;
|
||||||
interpret_program(&mut empty_state, 1000, 1000);
|
interpret_program(&mut empty_state, 1000, 1000);
|
||||||
|
|
||||||
let mut counts: Vec<(&str, usize)> = vec![];
|
|
||||||
counts.push(("int", 2));
|
|
||||||
counts.push(("float", 1));
|
|
||||||
|
|
||||||
// counts.iter().map()
|
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,3 @@ fn run_extract_test() {
|
|||||||
run_instruction!(aux_char, char, test_state, vector_char;);
|
run_instruction!(aux_char, char, test_state, vector_char;);
|
||||||
assert_eq!(vec!['a', 'b'], test_state.char);
|
assert_eq!(vec!['a', 'b'], test_state.char);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn instruction_list_test() {}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user