-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
48 lines (42 loc) · 990 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
46
47
48
#include <vector>
#include <iostream>
#include <sstream>
#include <fstream>
#include "parser.hpp"
#include "token.hpp"
#include "lexer.hpp"
#include "misc.hpp"
#include "astnode.hpp"
#include "printer.hpp"
#include "codegen.hpp"
using namespace std;
//Use tutorials in: https://llvm.org/docs/tutorial/
//=================================================================================================
int main (int argc, char *argv[])
{
if ( argc != 2 )
{
cout << "Expected file" << endl;
cout << " ./mila <filename>" << endl;
return 1;
}
ifstream fin ( argv[1] );
if ( ! fin.is_open () )
{
cout << "Couldn't open the file" << endl;
return 1;
}
vector<AST::ANode> nodes = CParser :: Analyse ( CLexer :: Analyse ( fin ) );
if ( ! g_HadError )
{
//CPrinter::Print ( nodes );
CCodeGen::Generate ( nodes );
}
else
{
cout << "There was a mistake in parsing the code" << endl;
return 1;
}
fin . close ();
return 0;
}