2014-04-07 04:23:28 +04:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
2014-04-07 07:13:14 +04:00
|
|
|
using Mal;
|
2014-04-07 04:23:28 +04:00
|
|
|
|
|
|
|
namespace Mal {
|
|
|
|
class step0_repl {
|
|
|
|
// read
|
|
|
|
static string READ(string str) {
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
// eval
|
|
|
|
static string EVAL(string ast, string env) {
|
|
|
|
return ast;
|
|
|
|
}
|
|
|
|
|
|
|
|
// print
|
|
|
|
static string PRINT(string exp) {
|
|
|
|
return exp;
|
|
|
|
}
|
|
|
|
|
2014-04-19 22:04:09 +04:00
|
|
|
// repl
|
2014-04-07 04:23:28 +04:00
|
|
|
static string RE(string env, string str) {
|
|
|
|
return EVAL(READ(str), env);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Main(string[] args) {
|
2015-03-07 18:04:07 +03:00
|
|
|
if (args.Length > 0 && args[0] == "--raw") {
|
|
|
|
Mal.readline.mode = Mal.readline.Mode.Raw;
|
|
|
|
}
|
2014-04-07 04:23:28 +04:00
|
|
|
|
2015-03-07 18:04:07 +03:00
|
|
|
// repl loop
|
2014-04-07 04:23:28 +04:00
|
|
|
while (true) {
|
|
|
|
string line;
|
|
|
|
try {
|
2015-03-07 18:04:07 +03:00
|
|
|
line = Mal.readline.Readline("user> ");
|
2014-04-07 04:23:28 +04:00
|
|
|
if (line == null) { break; }
|
2015-03-07 18:04:07 +03:00
|
|
|
if (line == "") { continue; }
|
2014-04-07 04:23:28 +04:00
|
|
|
} catch (IOException e) {
|
|
|
|
Console.WriteLine("IOException: " + e.Message);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Console.WriteLine(PRINT(RE(null, line)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|