-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
42 lines (36 loc) · 1001 Bytes
/
main.cpp
File metadata and controls
42 lines (36 loc) · 1001 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
#include<iostream>
#include "src/Utils/Utils.h"
#include "src/Models/Structs.h"
#include "src/Scanner/Scanner.h"
#include "src/Parser/Parser.h"
int main(int argc, char *argv[]){
// Check if the file is passed as an argument or not
// if not then error out
if(argc != 2){
std::cout<<"\nFile Missing , Invalid number of arguments\n";
return 1;
}
std::cout<<"----------------------------------------------------------------------------\n";
std::cout<<argv[1]<<std::endl;
std::cout<<"----------------------------------------------------------------------------\n";
// TESTING SCANNER
// Scanner scanner = Scanner(argv[1]);
// while(true){
// TokenRecord val = scanner.getToken();
// std::cout<<val;
// if(val.tokenType==EOT){
// break;
// }
// }
Parser parser = Parser(argv[1]);
try{
parser.parse();
}catch(std::runtime_error err){
std::cout<<"INVALID \n";
std::cout<<err.what();
exit(1);
}
std::cout<<"VALID CODE\n";
parser.showSymbolTable();
return 0;
}