12 this ->
start_time = -std::numeric_limits<decltype(start_time)>::max();
13 this ->
end_time = std::numeric_limits<decltype(end_time)>::max() ;
40 this ->
fh -> root_scope -> name = std::string(
"");
43 this ->
scopes.push(
this ->
fh -> root_scope);
45 tr -> add_scope(
scopes.top());
47 VCDParser::parser parser(*
this);
51 int result = parser.parse();
72 std::cerr <<
"line " << l.begin.line
74 std::cerr <<
" : " << m << std::endl;
78 std::cerr <<
" : "<<m<<std::endl;
81 #ifdef VCD_PARSER_STANDALONE 83 void print_scope_signals(
VCDScope * scope)
85 for(
VCDSignal * signal : scope -> signals) {
87 std::cout <<
"\t" << signal -> hash <<
"\t" 88 << signal -> reference;
90 if(signal -> size > 1) {
91 std::cout <<
"[" << signal -> lindex <<
":" << signal -> rindex <<
"]";
92 }
else if (signal -> lindex >= 0) {
93 std::cout <<
"[" << signal -> lindex <<
"]";
96 std::cout << std::endl;
101 void traverse_scope(std::string parent,
VCDScope * scope)
103 std::string local_parent = parent;
107 local_parent += scope->
name;
108 std::cout <<
"Scope: " << local_parent << std::endl;
109 print_scope_signals(scope);
110 for (
auto child : scope->
children) {
111 std::cout <<
"Child:\n";
112 traverse_scope(local_parent, child);
118 int main (
int argc,
char** argv){
120 std::string infile (argv[1]);
122 std::cout <<
"Parsing " << infile << std::endl;
129 std::cout <<
"Parse successful." << std::endl;
130 std::cout <<
"Version: " << trace -> version << std::endl;
131 std::cout <<
"Date: " << trace -> date << std::endl;
132 std::cout <<
"Signal count: " << trace -> get_signals() -> size() <<std::endl;
133 std::cout <<
"Times Recorded:" << trace -> get_timestamps() -> size() << std::endl;
136 for(
VCDScope * scope : *trace -> get_scopes()) {
139 traverse_scope(std::string(
""), scope);
146 std::cout <<
"Parse Failed." << std::endl;
void scan_end()
Utility function for stopping parsing.
VCDTime end_time
Ignore anything after this timepoint.
Class for parsing files containing CSP notation.
VCDScope * parent
Parent scope object.
bool trace_scanning
Should we debug tokenising?
VCDScope * root_scope
Root scope node of the VCD signals.
void error(const VCDParser::location &l, const std::string &m)
Reports errors to stderr.
std::vector< VCDScope * > children
Child scope objects.
Represents a single signal reference within a VCD file.
VCDScopeName name
The short name of the scope.
VCDFile * fh
Current file being parsed and constructed.
VCDTime start_time
Ignore anything before this timepoint.
Represents a scope type, scope name pair and all of it's child signals.
Contains the declaration of the parser driver class.
int main(int argc, char **argv)
Standalone test function to allow testing of the VCD file parser.
bool trace_parsing
Should we debug parsing of tokens?
VCDScopeType type
Construct type.
std::stack< VCDScope * > scopes
Current stack of scopes being parsed.
Top level object to represent a single VCD file.
VCDFileParser()
Create a new parser/.
VCDFile * parse_file(const std::string &filepath)
Parse the suppled file.
void scan_begin()
Utility function for starting parsing.
std::string filepath
The current file being parsed.