From cd0f4a0867738e9cad403ef802807325c0347887 Mon Sep 17 00:00:00 2001 From: Martin HART Date: Thu, 29 Oct 2020 14:34:04 +0100 Subject: [PATCH] Add shitty parser --- src/main.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main.rs b/src/main.rs index 13b6b44..13ad09e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -70,6 +70,32 @@ fn parse_config(conf: String, pool: &mut Vec) -> Result 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 }) }