-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (54 loc) · 1.5 KB
/
Copy pathmain.cpp
File metadata and controls
58 lines (54 loc) · 1.5 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
52
53
54
55
56
57
58
#include "Runtime.h"
#include "InternalFunctions.h"
using namespace std;
#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cmath>
RuaRuntime rrt;
void runFile(char* path) {
ifstream ifs;
ifs.open(path);
stringstream buffer;
buffer << ifs.rdbuf();
std::string contents(buffer.str());
ifs.close();
rrt.Preprocess(contents);
rrt.Run();
}
int main(int argc, char* argv[]) {
srand(time(NULL));
for (int i = 0; i < RuaInternalFuncCnt; i++) {
RuaData rd;
rd.f = new RuaFuncInfo;
memcpy_s(rd.f, sizeof(RuaFuncInfo), RuaInternalFuncInfoList + i, sizeof(RuaFuncInfo));
rrt.SetConstant(RuaInternalFunctionNames[i], RuaVariable(Function, rd, 0));
}
if (argc >= 2) {
runFile(argv[1]);
}
else {
string input, program;
printf("RuaLang alpha 1.2\n");
while (true)
{
printf("\n>>> ");
getline(cin, input);
if (input.empty()) continue;
program += input;
if (input[input.size() - 1] == '#') {
program = program.substr(0, program.size() - 1);
do
{
printf("+>> ");
getline(cin, input);
program += input;
} while (input[input.size() - 1] != '#');
//program = program.substr(0, program.size() - 1);
}
rrt.Execute(program);
program = "";
}
}
}