-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLispContext.cs
More file actions
47 lines (39 loc) · 846 Bytes
/
LispContext.cs
File metadata and controls
47 lines (39 loc) · 846 Bytes
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
using System;
using System.Collections.Generic;
namespace libQCLISP
{
public class LispContext
{
public Dictionary<string,ILispNative> registry;
public Dictionary<string,ILispValue> bank;
LispParser parsr;
public LispContext ()
{
parsr = new LispParser ();
registry = new Dictionary<string, ILispNative>();
bank = new Dictionary<string, ILispValue> ();
}
public ILispValue evaluate(string a)
{
return compile (a).eval ();
}
public ILispValue compile(string a)
{
return parsr.parse (a,registry,bank);
}
ILispValue execute(ILispValue a)
{
throw new NotImplementedException ();
}
public bool register(string cmd,ILispNative nat)
{
if (registry.ContainsKey (cmd)) {
registry [cmd] = nat;
return true;
} else {
registry.Add (cmd, nat);
return false;
}
}
}
}