-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.cpp
More file actions
50 lines (42 loc) · 1.06 KB
/
application.cpp
File metadata and controls
50 lines (42 loc) · 1.06 KB
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
#include <fstream>
#include "scanner.h"
#include <string>
#include "header_files/parser.h"
using namespace std;
int main(int argc, char const *argv[])
{
ifstream input_file;
ofstream output_file;
string current_line;
/* Check flags */
if (argc > 2)
{
if (strcmp(argv[2], "--debug") == 0)
{
freopen("debug.lexyc", "w", stdout);
}
}
/// Open Text File
input_file.open(argv[1]);
// Check File
if (!input_file)
{
cout << "[ERROR] Can't open file." << endl;
return 1;
}
/* Parse Text and Build Linked List of Tokens */
/* First Part: Lexycal Analysis */
Scanner *scanner = new Scanner();
while (input_file.peek() != EOF)
{
getline(input_file, current_line);
scanner->feed(current_line.c_str());
}
/* Parse List of valid Tokens */
/* Second Part: Syntatic Analysis */
TokenList *token_list = scanner->getTokenList();
Parser *parser = new Parser(token_list);
//parser->print();
parser->Program();
return 0;
}