forked from stevedonovan/cs-repl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
csrgui.cs
46 lines (38 loc) · 1.25 KB
/
csrgui.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
42
43
44
45
46
// CS-REPL: A simple C# REPL
// Copyright, Steve Donovan 2005-2013
// Use freely, but please acknowledge! (MIT license)
using System;
using System.IO;
using System.Windows.Forms;
public class RunCsi{
const string caption = "CS-REPL Simple C# Interpreter vs 0.8",
prompt = "> ";
static Interpreter interp = null;
static void ProcessLine(string line) {
interp.ProcessLine(line);
}
public static void Main(string[] args) {
GuiConsoleForm form = new GuiConsoleForm(caption,prompt,new StringHandler(ProcessLine));
GuiConsole console = new GuiConsole(form);
console.Write(caption+"\n"+prompt);
Interpreter.Console = console;
interp = new Interpreter();
string defs = args.Length > 0 ? args[0] : interp.DefaultIncludeFile();
interp.ReadIncludeFile(defs);
interp.SetValue("form",form);
interp.SetValue("text",form.TextBox);
Application.Run(form);
}
}
class GuiConsole : IConsole {
GuiConsoleForm form;
public GuiConsole(GuiConsoleForm f) {
form = f;
}
public string ReadLine() {
return "";
}
public void Write(string s) {
form.Write(s);
}
}