-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (30 loc) · 1.03 KB
/
main.cpp
File metadata and controls
36 lines (30 loc) · 1.03 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
#include <iostream>
#include <lexer.h>
#include <fstream>
#include <expressions.h>
#include <body.h>
#include <parser.h>
int main(int argc, char** argv)
{
if(argc > 1)
{
std::fstream fs;
fs.open(argv[1], std::fstream::in);
std::unique_ptr<nazkell::Lexer> l(new nazkell::Lexer(fs));
nazkell::Parser p(std::move(l));
std::unique_ptr<nazkell::Body> body;
body.reset(p.parse());
std::vector<std::shared_ptr<nazkell::Expression>> v;
for(int i = 2; i < argc; i++)
{
if(std::string(argv[i]) == "true" || std::string(argv[i]) == "false")
v.push_back(std::shared_ptr<nazkell::Expression>(new nazkell::BooleanExpression(std::string(argv[i]) == "true")));
else
v.push_back(std::shared_ptr<nazkell::Expression>(new nazkell::IntegerExpression(atoi(argv[i]))));
}
std::cout << body->evaluate(v, "Main").i << std::endl;
fs.close();
}
else
std::cout << "no input, executing..." << std::endl;
}