C#: add step5_tco
[jackhill/mal.git] / cs / step0_repl.cs
1 using System;
2 using System.IO;
3 using Mal;
4
5 namespace Mal {
6 class step0_repl {
7 // read
8 static string READ(string str) {
9 return str;
10 }
11
12 // eval
13 static string EVAL(string ast, string env) {
14 return ast;
15 }
16
17 // print
18 static string PRINT(string exp) {
19 return exp;
20 }
21
22 // REPL
23 static string RE(string env, string str) {
24 return EVAL(READ(str), env);
25 }
26
27 static void Main(string[] args) {
28 string prompt = "user> ";
29
30 while (true) {
31 string line;
32 try {
33 line = Mal.readline.Readline(prompt);
34 if (line == null) { break; }
35 } catch (IOException e) {
36 Console.WriteLine("IOException: " + e.Message);
37 break;
38 }
39 Console.WriteLine(PRINT(RE(null, line)));
40 }
41 }
42 }
43 }