-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
55 lines (49 loc) · 2.02 KB
/
Program.cs
File metadata and controls
55 lines (49 loc) · 2.02 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
using System;
using Ccf.Ck.Libs.ActionQuery;
namespace acexample
{
class Program
{
static void Main(string[] args)
{
Host host = new Host();
host.Trace = false;
host.TraceSteps = 100;
host.Parameters.Add("a", "string parameter a");
host.Parameters.Add("b", "string parameter b");
host.Parameters.Add("i", 10);
host.Parameters.Add("j", 0);
host.Parameters.Add("x", 1.23);
host.Parameters.Add("y", 0.56);
string line = null;
ActionQuery<ACValue> ac = new ActionQuery<ACValue>();
ActionQueryRunner<ACValue> runner;
Console.WriteLine("Press enter on empty line for exit or enter an expression and press enter to execute it.");
line = Console.ReadLine();
while (!string.IsNullOrWhiteSpace(line)) {
runner = ac.Compile(line);
if (runner.ErrorText != null) {
Console.WriteLine($"Compile error: {runner.ErrorText}");
Console.WriteLine("===> program dump ===");
Console.WriteLine(runner.DumpProgram());
Console.WriteLine("<=== end dump ===");
Console.WriteLine("try again");
} else {
Console.WriteLine("=== program dump ===");
Console.WriteLine(runner.DumpProgram());
Console.WriteLine("=== program run follows ===");
try {
ACValue result = runner.ExecuteScalar(host);
Console.WriteLine($"Executed, result = {result.Value}");
Console.WriteLine("try again");
} catch (Exception ex) {
Console.WriteLine(ex);
Console.WriteLine("try again");
}
}
line = Console.ReadLine();
}
Console.WriteLine("Exiting ...");
}
}
}