use exers::{
common::{
builder::RuntimeBuilder,
preprocessor::{Preprocessor, PreprocessorResult},
},
compilers::rust_compiler::RustCompiler,
runtimes::native_runtime::NativeRuntime,
};
#[derive()]
pub struct RemoveDolarSignsPreprocessor;
impl Preprocessor for RemoveDolarSignsPreprocessor {
fn preprocess(&self, code: &str) -> PreprocessorResult<String> {
Ok(code.replace("$", ""))
}
}
fn main() {
let code1 = r#"
$fn main() {
println!("Hi! I'm the first program!");
}$
"#;
let code2 = r#"
fn main() {
print$ln!("And $I'm the second program!");
}
"#;
let rust_native_runtime = RuntimeBuilder::new()
.preprocessor(RemoveDolarSignsPreprocessor)
.compiler(RustCompiler, None) .runtime(NativeRuntime, None) .build()
.unwrap();
println!(
"First program: {:?}",
rust_native_runtime(&mut code1.as_bytes())
);
println!(
"Second program: {:?}",
rust_native_runtime(&mut code2.as_bytes())
);
}