-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrolton-basic.cpp
More file actions
41 lines (36 loc) · 1.36 KB
/
rolton-basic.cpp
File metadata and controls
41 lines (36 loc) · 1.36 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
#include <iostream>
#include <fstream>
#include <vector>
#include <string.h>
#include <cstring>
#include "parser.hpp"
#include "lexer.hpp"
#include "compiler.hpp"
#include "types.hpp"
using namespace std;
int main(int argc, char** argv) {
string line;
vector<rbl_types::ast_type> ast_full;
vector<rbl_types::var> vars_vector = {{"SYSVERSION", "string", "1.0.1-alpha"}, {"SYSDEVELOPER", "string", "KirillMos1"}};
do {
cout<<"\n\nEnter code: ";
getline(cin, line);
if (line == "EXIT") {continue;} // TODO 0xd001 / 0xd0000001 Fix. if input " EXIT" it DOESNT WORK but it MUST work / Починить. Если ввод " EXIT" то это НИХРЕНА не работает, А НАДО
cout<<"[LOG] START LEXER\n";
vector<lexer::token> tokens = lexer::lexering(line);
cout<<"[LOG] START PARSER\n";
rbl_types::ast_type ast = parser::parse(tokens);
cout<<"[LOG] ADD IN FULL AST\n";
ast_full.push_back(ast);
} while (line != "EXIT"); // TODO 0xd001 / 0xd0000001
cout<<"[LOG] START TRANSLATING\n";
string translated = compiler::translating(ast_full, vars_vector);
std::cout << "Your name for out file: program";
std::ofstream out;
out.open("programm.c");
if (out.is_open()) {
out << translated << endl;
}
out.close();
system("gcc programm.c -o programm");
}