Add shitty parser

This commit is contained in:
Martin HART 2020-10-29 14:34:04 +01:00
parent d2058ef71d
commit cd0f4a0867
1 changed files with 26 additions and 0 deletions

View File

@ -70,6 +70,32 @@ fn parse_config(conf: String, pool: &mut Vec<robot::Robot>) -> Result<world::Wor
Ok(x) => x,
Err(_) => return Err("Could not convert token two from the first string to i32"),
};
loop {
// This line should be empty.
let empty_line = match lines.next() {
None => break,
Some(x) => x,
};
if !empty_line.is_empty() {
return Err("This line should be empty !");
}
let a = match lines.next() {
None => return Err("This line should be config !"),
Some(raw) => raw,
};
if a.is_empty() {
return Err("The config line should be empty !");
}
let b = match lines.next() {
None => return Err("This line should be instruction !"),
Some(raw) => raw,
};
if b.is_empty() {
return Err("The instruction line should be empty !");
}
println!("{}", a);
println!("{}", b);
}
Ok(world::World { x, y })
}