-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
45 lines (38 loc) · 898 Bytes
/
main.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
#include <bits/stdc++.h>
#include "./lexer.h"
#include "./highlight.h"
using namespace std;
int main(int argc, char **argv)
{
string program;
if (argc < 2)
{
cerr << "ERROR: Filename is not provided\n";
exit(1);
}
ifstream filestream(argv[1]);
string s;
s += (char)filestream.get();
while (filestream.good())
{
s += filestream.get();
}
program = s;
filestream.close();
Language lang = find_file_language(argv[1]);
Lexer lex = Lexer(program.c_str(), program.size(), lang);
vector<Token> tokenised_program;
Token tok;
tok = lex.next();
while (tok.kind != TOKEN_END)
{
tokenised_program.push_back(tok);
tok = lex.next();
}
HightLight output = HightLight(tokenised_program);
output.printToConsole();
return 0;
}
/*
For C/C++ Multiline comment is not supported.
*/