-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathPSL.cpp
52 lines (46 loc) · 773 Bytes
/
PSL.cpp
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
#include "PSL/PSL.h"
#include <stdio.h>
#ifdef _WIN32
#include <conio.h>
#else
#define getch getchar
#endif
int main(int argc, char **argv)
{
if (argc < 2)
return 0;
using namespace PSL;
PSLVM p;
if (PSLVM::error e = p.loadScript(argv[1]))
{
if (e == PSLVM::FOPEN_ERROR)
{
string input = argv[1];
for (int i = 2; i < argc; ++i)
{
input += ' ';
input += argv[i];
}
input += ';';
p.loadString(input);
variable v = p.run();
printf("%s", v.toString().c_str());
return 0;
}
else
{
printf(" - compile error\n");
}
}
else
{
if (argc > 2)
p.writeCompiledCode(argv[2]);
#ifdef PSL_DEBUG
variable r;
while (!(r = p.stepExec())) if (getch() == 'q')break;
#endif
variable v = p.run(argv[1]);
}
return 0;
}