-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
46 lines (37 loc) · 995 Bytes
/
main.cpp
File metadata and controls
46 lines (37 loc) · 995 Bytes
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
#include <iostream>
#include <fstream>
#include <string>
#include "dfa.h"
using namespace std;
// Main Function Code
int main(int argc, const char **argv)
{
DFA lexer;
string tokens;
string ids;
fstream fin;
fin.open(argv[1], ios::in);
//fin.open("file.txt", ios::in);
if (fin.is_open())
{ //checking whether the file is open
string word = "";
char chr;
while (!fin.eof())
{
fin.get(chr); // read a character
lexer.performTransistion(chr);
}
fin.close(); //close the file object.
}
//cout << endl << endl << "******************* MAIN -- MMMAAAIIINNN -- MAIN *******************" << endl;
//cout << lexer.getTokens() << endl << endl;
//cout << lexer.getIds() << endl;
ofstream out;
out.open("words.txt");
out << lexer.getTokens();
out.close();
out.open("table.txt");
out << lexer.getIds();
out.close();
return 0;
}