-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTestRhoSyntax.cpp
More file actions
42 lines (32 loc) · 1.09 KB
/
TestRhoSyntax.cpp
File metadata and controls
42 lines (32 loc) · 1.09 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
#include <KAI/Console/Console.h>
#include <iostream>
using namespace kai;
int main() {
try {
Console console;
console.SetLanguage(Language::Rho);
// Test 1: Simple assignment and retrieval
std::cout << "Test 1: Simple assignment\n";
console.Execute("x = 42");
console.Execute("x");
auto executor = console.GetExecutor();
auto dataStack = executor->GetDataStack();
if (!dataStack->Empty()) {
auto val = dataStack->Top();
std::cout << "Result: " << val.ToString() << std::endl;
dataStack->Pop();
}
// Test 2: If statement
std::cout << "\nTest 2: If statement\n";
console.Execute("result = 0");
console.Execute("if true { result = 99 }");
console.Execute("result");
if (!dataStack->Empty()) {
auto val = dataStack->Top();
std::cout << "Result after if: " << val.ToString() << std::endl;
}
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
return 0;
}