diff --git a/README.md b/README.md index d89ed64..bca4068 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ a large VCD file from The first build of the program may take some time. -``cargo run --release -- path/to/vcd/file`` +``cargo run --release test-vcd-files/aldec/SPI_Write.vcd`` ## TODO - [ ] We need a way to merge lines. diff --git a/src/main.rs b/src/main.rs index 2171697..51a3ca2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,19 @@ struct Timestamp{ timestamp: BigInt } +struct Cursor{ + line: u64, + col : u64 +} + +enum Tokens { + Date, + End, + String, + Version, + Time, +} + struct Signal { name : String, timeline : BTreeMap, @@ -35,12 +48,33 @@ fn main() -> std::io::Result<()> { let mut buffer = Vec::::new(); let mut word_count = 0u64; - while { - let bytes_read = reader.read_until(space, &mut buffer).unwrap(); - bytes_read > 0 - } { + // while { + // let bytes_read = reader.read_until(b' ', &mut buffer).unwrap(); + // bytes_read > 0 + // } { + // word_count += 1; + + // if word_count < 5 { + // let string = std::str::from_utf8(&buffer).unwrap(); + // dbg!(string); + // } + // buffer.clear(); + // } + loop { + buffer.clear(); + let t = reader + .by_ref() + .bytes() + .map(|c| c.unwrap()) + .take_while(|c| + c != &b' ' && + c != &b'\n'); + buffer.extend(t); word_count += 1; + } + let string = std::str::from_utf8(&buffer).unwrap(); + dbg!(string); dbg!(word_count); Ok(())