New parser #2
|
@ -3,10 +3,12 @@ PROPRIETARY - Copyright - Yehowshua Immanuel
|
|||
|
||||
# The Beginnings of a high-performance, low memory footprint VCD Viewer in Rust for massive multi-GB waveforms
|
||||
|
||||
## Features
|
||||
## Current Features
|
||||
- very fast
|
||||
- loads 200MB of VCD waveform per second on an 8 core 2017 desktop CPU with NVMe storage
|
||||
- loads 400MB of VCD waveform per second on an 8 core 2017 desktop CPU with NVMe storage
|
||||
- consumes roughly between 10 - 50MB of memory per GB of waveform
|
||||
|
||||
## Planed Features
|
||||
- elegant/pretty UI
|
||||
- can be easily ported to work in browser via webassembly
|
||||
- allows high-performance custom Rust plugins to manipulate and
|
||||
|
|
49
src/main.rs
49
src/main.rs
|
@ -52,11 +52,14 @@ struct VCD {
|
|||
|
||||
#[derive(Debug)]
|
||||
enum Date_Parser_State {Weekday, Month, Day, HHMMSS, Year}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum VCD_Parser_State {
|
||||
Begin,
|
||||
Date(Date_Parser_State),
|
||||
Signal_Tree, Values}
|
||||
Parse_Version,
|
||||
Parse_Signal_Tree,
|
||||
Parse_Signal_Values}
|
||||
|
||||
struct DateBuffer {
|
||||
Weekday : String,
|
||||
|
@ -70,7 +73,7 @@ struct VCD_Parser<'a> {
|
|||
date_parser_state : Date_Parser_State,
|
||||
date_buffer : DateBuffer,
|
||||
|
||||
vcd : &'a VCD,
|
||||
vcd : &'a mut VCD,
|
||||
curr_scope : &'a Scope,
|
||||
curr_parent_scope : &'a Scope}
|
||||
|
||||
|
@ -90,7 +93,7 @@ impl VCD {
|
|||
all_scopes : Vec::<Scope>::new()}}}
|
||||
|
||||
impl<'a> VCD_Parser<'a> {
|
||||
pub fn new(&mut self, vcd : &'a VCD) {
|
||||
pub fn new(&mut self, vcd : &'a mut VCD) {
|
||||
self.vcd_parser_state = VCD_Parser_State::Begin;
|
||||
self.date_parser_state = Date_Parser_State::Weekday;
|
||||
self.vcd = vcd;}
|
||||
|
@ -100,7 +103,11 @@ impl<'a> VCD_Parser<'a> {
|
|||
match state {
|
||||
VCD_Parser_State::Begin => {
|
||||
match word {
|
||||
"$date" => {*state = VCD_Parser_State::Date(Date_Parser_State::Weekday); Ok(())},
|
||||
"$date" =>
|
||||
{
|
||||
*state = VCD_Parser_State::Date(Date_Parser_State::Weekday);
|
||||
Ok(())
|
||||
}
|
||||
// "$version" => {*state = VCD_Parser_State::VERSION_ENTER; Ok(())},
|
||||
// "$timescale" => {*state = VCD_Parser_State::TIMESCALE_ENTER; Ok(())},
|
||||
_ => Err(format!("unsure what to do with {word:?}"))}},
|
||||
|
@ -124,7 +131,39 @@ impl<'a> VCD_Parser<'a> {
|
|||
*state = VCD_Parser_State::Date(Date_Parser_State::Day);
|
||||
Ok(())
|
||||
}
|
||||
_ => Err(format!("unsure what to do with {state:?}")),
|
||||
VCD_Parser_State::Date(Date_Parser_State::Day) =>
|
||||
{
|
||||
self.date_buffer.Day = word.to_string();
|
||||
*state = VCD_Parser_State::Date(Date_Parser_State::HHMMSS);
|
||||
Ok(())
|
||||
}
|
||||
VCD_Parser_State::Date(Date_Parser_State::HHMMSS) =>
|
||||
{
|
||||
self.date_buffer.HHMMSS = word.to_string();
|
||||
*state = VCD_Parser_State::Date(Date_Parser_State::Year);
|
||||
Ok(())
|
||||
}
|
||||
VCD_Parser_State::Date(Date_Parser_State::Year) =>
|
||||
{
|
||||
self.date_buffer.Year = word.to_string();
|
||||
|
||||
// now that we've successfully parsed all the date information,
|
||||
// we store it to a d
|
||||
let weekday = &self.date_buffer.Weekday;
|
||||
let month = &self.date_buffer.Month;
|
||||
let day = &self.date_buffer.Day;
|
||||
let hhmmss = &self.date_buffer.HHMMSS;
|
||||
let year = &self.date_buffer.Year;
|
||||
|
||||
let date = &format!("{weekday} {month} {day} {hhmmss} {year}")[..];
|
||||
let dt = Utc.datetime_from_str(date, "%a %b %e %T %Y").unwrap();
|
||||
|
||||
self.vcd.metadata.date = dt;
|
||||
|
||||
*state = VCD_Parser_State::Parse_Version;
|
||||
Ok(())
|
||||
}
|
||||
_ => Err(format!("{state:?} should be unreachable within DateParser.")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue