Added a fmt file and formatted the whole project
parent
659f9fbe65
commit
f39dde9c64
|
@ -0,0 +1,8 @@
|
||||||
|
unstable_features = true
|
||||||
|
reorder_imports = true
|
||||||
|
hard_tabs = true
|
||||||
|
control_brace_style = "ClosingNextLine"
|
||||||
|
imports_granularity = "Crate"
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
edition = "2021"
|
||||||
|
newline_style = "Unix"
|
|
@ -16,7 +16,8 @@ pub fn run(program: Vec<u8>) {
|
||||||
for (ip, instruction) in program.iter().enumerate() {
|
for (ip, instruction) in program.iter().enumerate() {
|
||||||
if *instruction == b'[' {
|
if *instruction == b'[' {
|
||||||
stack.push_back(ip);
|
stack.push_back(ip);
|
||||||
} else if *instruction == b']' {
|
}
|
||||||
|
else if *instruction == b']' {
|
||||||
let begin_index = stack.pop_back().unwrap();
|
let begin_index = stack.pop_back().unwrap();
|
||||||
table.insert(begin_index, ip);
|
table.insert(begin_index, ip);
|
||||||
table.insert(ip, begin_index);
|
table.insert(ip, begin_index);
|
||||||
|
@ -24,7 +25,8 @@ pub fn run(program: Vec<u8>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
while ip < program.len() {
|
while ip < program.len() {
|
||||||
let Some(instruction) = program.get(ip) else {
|
let Some(instruction) = program.get(ip)
|
||||||
|
else {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@ pub fn tokenize(program: Vec<u8>) -> Vec<Token> {
|
||||||
|
|
||||||
let mut ip = 0;
|
let mut ip = 0;
|
||||||
while ip < program.len() {
|
while ip < program.len() {
|
||||||
let Some(instruction) = program.get(ip) else {
|
let Some(instruction) = program.get(ip)
|
||||||
|
else {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue