New parser #2
|
@ -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.
|
||||
|
|
42
src/main.rs
42
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<BigInt, BigInt>,
|
||||
|
@ -35,12 +48,33 @@ fn main() -> std::io::Result<()> {
|
|||
let mut buffer = Vec::<u8>::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(())
|
||||
|
|
Loading…
Reference in a new issue