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
extern crate bfcore; use bfcore::Input; use crate::Lang; #[derive(Default, Debug, Clone)] pub struct CompilerInput { lang: Lang, index: usize, input_script: String } impl CompilerInput { pub fn new(lang: Lang, input_script: String) -> Self { Self { lang, index: 0, input_script:lang.script_header().to_string() + &input_script } } } impl Input for CompilerInput { fn input(&mut self) -> char { match self.input_script.chars().nth(self.index) { Some(ch) => { self.index += 1; ch }, None => '\0' } } }