Improve the code yooo 🥰🦀
This commit is contained in:
parent
da1f1ea567
commit
93e792088c
|
@ -1,6 +1,6 @@
|
||||||
use crate::arguments;
|
use crate::arguments;
|
||||||
use crate::bf_interpreter::error::{InterpreterError, InterpreterErrorKind};
|
use crate::bf_interpreter::error::{InterpreterError, InterpreterErrorKind};
|
||||||
use std::io::{BufRead, Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::{char, usize, vec};
|
use std::{char, usize, vec};
|
||||||
|
|
||||||
pub struct Interpreter {
|
pub struct Interpreter {
|
||||||
|
|
|
@ -3,7 +3,7 @@ mod repl;
|
||||||
mod utils;
|
mod utils;
|
||||||
mod bf_interpreter;
|
mod bf_interpreter;
|
||||||
|
|
||||||
use std::io::{BufRead, Write};
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
extern crate pretty_env_logger;
|
extern crate pretty_env_logger;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
14
src/repl.rs
14
src/repl.rs
|
@ -1,10 +1,10 @@
|
||||||
use crate::bf_interpreter::interpreter::Interpreter;
|
use crate::bf_interpreter::interpreter::Interpreter;
|
||||||
use std::io::{Write, Read, BufRead, BufReader, Stdout, Stdin};
|
use std::io::{Write, BufRead};
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use no_panic::no_panic;
|
|
||||||
|
|
||||||
struct Repl {
|
struct Repl {
|
||||||
interpreter: Interpreter,
|
pub interpreter: Interpreter,
|
||||||
history: Vec<String>,
|
history: Vec<String>,
|
||||||
loop_body: String,
|
loop_body: String,
|
||||||
loop_depth: usize,
|
loop_depth: usize,
|
||||||
|
@ -211,12 +211,6 @@ impl Repl {
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the interpreter
|
|
||||||
/// for testing purposes only!
|
|
||||||
pub fn interpreter(&self) -> &Interpreter {
|
|
||||||
&self.interpreter
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run the REPL
|
/// Run the REPL
|
||||||
|
@ -267,7 +261,7 @@ mod tests {
|
||||||
repl.process("[>+<-]".to_string());
|
repl.process("[>+<-]".to_string());
|
||||||
repl.process("<-]".to_string());
|
repl.process("<-]".to_string());
|
||||||
|
|
||||||
let cells = &repl.interpreter().cells;
|
let cells = &repl.interpreter.cells;
|
||||||
|
|
||||||
assert_eq!(cells[0], 0);
|
assert_eq!(cells[0], 0);
|
||||||
assert_eq!(cells[1], 0);
|
assert_eq!(cells[1], 0);
|
||||||
|
|
Loading…
Reference in New Issue