New parser #2

Merged
ThePerfectComputer merged 51 commits from new_parser into main 2022-08-01 21:00:00 +00:00
2 changed files with 39 additions and 5 deletions
Showing only changes of commit da0bc62102 - Show all commits

View file

@ -17,7 +17,7 @@ a large VCD file from
The first build of the program may take some time. 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 ## TODO
- [ ] We need a way to merge lines. - [ ] We need a way to merge lines.

View file

@ -18,6 +18,19 @@ struct Timestamp{
timestamp: BigInt timestamp: BigInt
} }
struct Cursor{
line: u64,
col : u64
}
enum Tokens {
Date,
End,
String,
Version,
Time,
}
struct Signal { struct Signal {
name : String, name : String,
timeline : BTreeMap<BigInt, BigInt>, timeline : BTreeMap<BigInt, BigInt>,
@ -35,12 +48,33 @@ fn main() -> std::io::Result<()> {
let mut buffer = Vec::<u8>::new(); let mut buffer = Vec::<u8>::new();
let mut word_count = 0u64; let mut word_count = 0u64;
while { // while {
let bytes_read = reader.read_until(space, &mut buffer).unwrap(); // let bytes_read = reader.read_until(b' ', &mut buffer).unwrap();
bytes_read > 0 // 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; word_count += 1;
} }
let string = std::str::from_utf8(&buffer).unwrap();
dbg!(string);
dbg!(word_count); dbg!(word_count);
Ok(()) Ok(())