forked from microsoft/schemy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
41 lines (37 loc) · 1.33 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
39
40
41
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
namespace Schemy
{
using System;
using System.IO;
public static class Program
{
public static void Main(string[] args)
{
if (args.Length > 0 && File.Exists(args[0]))
{
// evaluate input file's content
var file = args[0];
var interpreter = new Interpreter(null, new ReadOnlyFileSystemAccessor());
using (TextReader reader = new StreamReader(file))
{
object res = interpreter.Evaluate(reader);
Console.WriteLine(Utils.PrintExpr(res));
}
}
else
{
// starts the REPL
var interpreter = new Interpreter(null, new ReadOnlyFileSystemAccessor());
var headers = new[]
{
"-----------------------------------------------",
"| Schemy - Scheme as a Configuration Language |",
"| Press Ctrl-C to exit |",
"-----------------------------------------------",
};
interpreter.REPL(Console.In, Console.Out, "Schemy> ", headers);
}
}
}
}