-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcosl.cpp
More file actions
51 lines (50 loc) · 1.73 KB
/
Copy pathcosl.cpp
File metadata and controls
51 lines (50 loc) · 1.73 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
51
#include "lexer.hpp"
#include "parser.hpp"
#include "ast.hpp"
#include "resolver.hpp"
#include "typechecker.hpp"
int main(int argc, char* argv[]){
LOG("starting")
lexer::genLexer lexer("TOKENS");
auto lex = lexer.getLexer();
if(argc < 2){
std::cout << "Usage: cosl <osl-program>" << std::endl;
return 1;
}
std::vector<Token> tokens = lex(argv[1]);
LOG("Tokenized")
//std::cout << "Lexer Result:\n";
//std::string isValToken[] = {"IDEN","NUM","BOOL"};
/*for(Token token: tokens){
std::cout << token << std::endl;
if(isValToken(token.getId())){
std::cout << "Value: " << token.getVal() << std::endl;
}
}*/
std::cout << "Tokenization Done Successfully" << std::endl;
LOG("")
LOG("starting parse")
parser::genParser parser("GRAMMAR", lexer.allTokens, lexer.dfa.desc, lexer.dfa.lines);
LOG("obj created")
auto parse = parser.getParser();
LOG("parser generated")
parser::parseTree tree = parse(tokens);
LOG("parsed")
std::cout << "Parsing Done Successfully" << std::endl;
//std::cout << "\nParser Result:\n";
/*if(tree.getNodeCnt() != 0){
parser::vizTree(tree, 0, "", true);
}*/
std::unique_ptr<ast::ASTNode> root = ast::parseTreeToAST(tree);
std::cout << "AST Tree Formed Successfully" << std::endl;
LOG("ast formed")
// ast::vizTree(root, "", true);
LOG("about to start resolution")
Resolver resolver(root);
std::cout << "Resolution Performed Successfully" << std::endl;
// ast::vizTree(root, "", true, true);
LOG("resolution done successfully")
typecheck::TypeChecker tc(std::move(root));
std::cout << "Typechecking Performed Successfully" << std::endl;
return 0;
}