Add shitty parser
This commit is contained in:
parent
d2058ef71d
commit
cd0f4a0867
26
src/main.rs
26
src/main.rs
@ -70,6 +70,32 @@ fn parse_config(conf: String, pool: &mut Vec<robot::Robot>) -> Result<world::Wor
|
|||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(_) => return Err("Could not convert token two from the first string to i32"),
|
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 })
|
Ok(world::World { x, y })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user