-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmain.cpp
44 lines (41 loc) · 807 Bytes
/
tmain.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
#include <iostream>
#include <fstream>
#include "interpretlib.h"
#ifndef PROG_PATH
#define PROG_PATH "./input_file.js"
#endif
int main(){
//vector<string> TS; // table of strings
ofstream out ("output_file");
const char* program = PROG_PATH;
Scanner scanner ( program );
try
{
int str_k;
Lexem lex;
int k = 0;
while (lex.get_type() != LEX_FIN)
{
if ( ++k % 10 == 0) out << endl;
lex = scanner.get_lex(&str_k);
out << lex;
}
}
catch(invalid_argument& err)
{
cerr << "Exception catched : " << err.what() << endl;
}
catch(char& c)
{
cerr << "Exception catched : lex error : " << c << endl;
}
out << endl << endl;
int i=1;
vector <string>::const_iterator p = scanner.TS.begin();
while(p!=scanner.TS.end()){
out << i <<" "<< *p << endl;
p++;
i++;
}
return 0;
}