-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
38 lines (34 loc) · 1.15 KB
/
Program.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lisp {
public class Program {
/// <summary>
/// This program interprets and executes the eval.lisp code, and then drops to a kind of REPL
/// </summary>
public static void Main(string[] args) {
var context = StandardLibrary.NewContext();
try {
foreach (var expression in Reader.ReadFile("eval.lisp")) {
Console.WriteLine(expression);
context.Evaluate(expression);
}
} catch (LispException ex) {
Console.WriteLine("Error while executing eval.lisp", ex);
}
var line = Console.ReadLine();
while (line != "exit") {
try {
Console.WriteLine(context.Evaluate(line));
} catch (LispException ex) {
Console.WriteLine(ex);
}
line = Console.ReadLine();
}
Console.WriteLine("Done");
Console.ReadKey(true);
}
}
}