-
Notifications
You must be signed in to change notification settings - Fork 7
/
parser.cpp
executable file
·140 lines (123 loc) · 4.45 KB
/
parser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
* This is written by Zhiyang Ong to parse a STIL file into a FLAT tabular
* test pattern format that contains input test patterns for execution on
* automatic test equipment
* Main function...
*/
// Import Header files from the C++ STL
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <math.h>
#include "file_analyzer.h"
using namespace std;
// Instance variables
// Names for input and output file streams
string input_filename;
string output_filename;
// =======================================================================
// Start of main function...
int main(int argc, char *argv[]) {
cout << "========================================================" << endl;
cout << "Start parsing the STIL input file... And process it."<<endl;
/*
* If the first two input arguments for this program is null,
* request for the user to rerun the program and exit.
*/
if((argv[1] == NULL) || (argv[2] == NULL)) {
cout << "Please enter the names for the input and output files" << endl;
cout << "when you rerun this program" << endl;
cout << "i.e., [program name] [input filename] [output filename]" << endl;
return 0;
}else{
// Assign the first input argument to the program as the input filename
input_filename = argv[1];
// Assign the 2nd input argument to the program as the output filename
output_filename = argv[2];
}
// Delete this block of code
cout << "1st argument..." << endl;
cout << input_filename << endl;
cout << "2nd argument" << endl;
cout << output_filename << endl;
// Prepare to parse the input file, process it, and produce the output file
file_analyzer *fa = new file_analyzer(input_filename, output_filename);
/**
* Parse the input file to produce an output text file indicating the
* test patterns for the automatic test equipment
*/
fa->parse_input();
string be = fa->time_to_string(35, 1);
// Try to see if the static method in SignalZ will work
/*
signalZ::set_sig_period(756);
cout<<"Val of period in SignalZ:"<<signalZ::get_sig_period()<<"<:::"<<endl;
*/
cout << "1Test pattern:::" << be << endl;
be = fa->time_to_string(20, 0);
cout << "2Test pattern:::" << be << endl;
be = fa->int_to_str(5126759);
cout << "3Test pattern:::" << be << endl;
// signal *za = new signal("sigNamE",(*fa));
/*
cout << "delimit string" << endl;
str_list a = fa->delimit_string("sa123d '23sd' 1e dm23 -=32-42 0-2359%^&%bgjhgbug&*^*(G");
str_l_p p = a.begin();
while(p != a.end()) {
cout << "Current token is:::" << (*p) << endl;
p++;
}
*/
/*
cout << "delimit string" << endl;
cout << "string IS" << "'23sd'" << endl;
str_list a = fa->delimit_string("'23sd'");
cout << "size of string" << a.size() << endl;
str_l_p p = a.begin();
while(p != a.end()) {
cout << "Current token is:::" << (*p) << endl;
p++;
}
cout << "string IS" << "#$%^& y1234y u23149 83u84 *(^&" << endl;
a = fa->delimit_string("#$%^& y1234y 'u23149' 83u84 *(^&");
cout << "size of string" << a.size() << endl;
p = a.begin();
while(p != a.end()) {
cout << "Current token is:::" << (*p) << endl;
p++;
}
cout << "string IS" << "gauyg212 jhg324 'g24j3yg' 70981" << endl;
a = fa->delimit_string("gauyg212 jhg324 'g24j3yg' 'w'70981");
cout << "size of string" << a.size() << endl;
p = a.begin();
while(p != a.end()) {
cout << "Current token is:::" << (*p) << endl;
p++;
}
cout << "string IS" << "gasdy hugdqeuyo oygwe ''y19y''" << endl;
a = fa->delimit_string("gasdy hugdqeuyo oygwe ''y19y''");
cout << "size of string" << a.size() << endl;
p = a.begin();
while(p != a.end()) {
cout << "Current token is:::" << (*p) << endl;
p++;
}
cout<<"1TRUN:::"<<fa->truncate_whitespace(" giui hyyiuh ")<<endl;
cout<<"2TRUN:::"<<fa->truncate_whitespace("guy hiuh hiui877")<<endl;
cout<<"3TRUN:::"<<fa->truncate_whitespace("#$%^&*SDFGH t786 * T* J ")<<endl;
*/
cout << "========================================================" << endl;
cout << "Note that the logic values are represented every ";
cout << file_analyzer::MEASURE_OF_TIME << file_analyzer::UNIT_OF_TIME;
cout << " in time." << endl;
cout << "" << endl;
cout << "Definition for logic values of signals:" << endl;
cout << "Logic zero: "<< signalZ::LOGIC_ZERO << endl;
cout << "Logic one: "<< signalZ::LOGIC_ONE << endl;
cout << "Logic at high impedance: "<< signalZ::LOGIC_HIGH_IMPEDANCE << endl;
cout << "Logic is undefined: "<< signalZ::LOGIC_UNDEFINED << endl;
cout << "========================================================" << endl;
// End of main function...
return 0;
}