Fix rewinding

master
trivernis 4 years ago
parent 077684c681
commit 463f2ffee1

@ -1,6 +1,6 @@
[package] [package]
name = "charred" name = "charred"
version = "0.3.0" version = "0.3.1"
authors = ["trivernis <trivernis@protonmail.com>"] authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018" edition = "2018"
license-file = "LICENSE" license-file = "LICENSE"

@ -94,6 +94,9 @@ impl CharTapeMachine {
if self.text.len() > index { if self.text.len() > index {
self.index = index; self.index = index;
self.current_char = *self.text.get(index).unwrap(); self.current_char = *self.text.get(index).unwrap();
if self.index > 0 {
self.previous_char = *self.text.get(index - 1).unwrap();
}
} }
} }
@ -379,7 +382,7 @@ impl CharTapeMachine {
if self.check_any(until) { if self.check_any(until) {
return Ok(result); return Ok(result);
} else if self.check_any(err_at) { } else if self.check_any(err_at) {
return Err(TapeError::new(self.index)); return Err(self.rewind_with_error(rewind_index));
} }
result.push(self.current_char); result.push(self.current_char);

Loading…
Cancel
Save