aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rust/bf/.vscode/launch.json15
-rw-r--r--rust/bf/src/main.rs6
2 files changed, 18 insertions, 3 deletions
diff --git a/rust/bf/.vscode/launch.json b/rust/bf/.vscode/launch.json
new file mode 100644
index 0000000..33bcb32
--- /dev/null
+++ b/rust/bf/.vscode/launch.json
@@ -0,0 +1,15 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "lldb",
+ "request": "launch",
+ "name": "Debug executable",
+ "cargo": {
+ "args": ["build"]
+ },
+ "args": ["src/hw.bf"],
+ "cwd": "${workspaceFolder}"
+ }
+ ]
+} \ No newline at end of file
diff --git a/rust/bf/src/main.rs b/rust/bf/src/main.rs
index 9257ae2..e511e69 100644
--- a/rust/bf/src/main.rs
+++ b/rust/bf/src/main.rs
@@ -16,12 +16,12 @@ fn interpret_brainfuck(code: &str) {
'>' => {
pointer += 1;
if pointer >= memory.len() {
- panic!("Pointer out of bounds");
+ panic!("Pointer out of bounds (positive)");
}
}
'<' => {
if pointer == 0 {
- panic!("Pointer out of bounds");
+ panic!("Pointer out of bounds (negative)");
}
pointer -= 1;
}
@@ -36,7 +36,7 @@ fn interpret_brainfuck(code: &str) {
}
',' => {
let mut input = [0u8];
- io::stdin().read_exact(&mut input).expect("Failed to read input");
+ io::stdin().read_exact(&mut input).expect("Failed to read input. Unable to read a single byte from stdin");
memory[pointer] = input[0];
}
'[' => {