-
Notifications
You must be signed in to change notification settings - Fork 0
/
repl.html
44 lines (44 loc) · 1.03 KB
/
repl.html
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
<!doctype HTML>
<html>
<head>
<title>fffff REPL</title>
<script src="ops.js"></script>
<script src="values.js"></script>
<script src="parser.js"></script>
<script src="main.js"></script>
<script src="https://kaya3.github.io/console-app-js/consoleapp.min.js"></script>
</head>
<body>
<script type="text/javascript">
var parser, interpreter, repl = ConsoleApp({
prompt: '>>> ',
onCommand: function(c) {
c = c.trim();
if(c === '/reset') { reset(); return; }
parser.read(c);
var q = parser.parse();
if(q) {
interpreter.execQuote(q);
repl.setPrompt('>>> ');
repl.println('\n' + interpreter.toString());
} else {
repl.setPrompt('... ');
}
},
onError: function(e) {
repl.println(e.message, 'color: red');
repl.println(interpreter.stackTrace(), 'color: red');
repl.println('\n' + interpreter.toString());
},
});
function reset() {
parser = new Parser();
interpreter = new Interpreter(repl.print);
repl.clear();
repl.println('fffff REPL\n');
repl.println(interpreter.toString());
}
reset();
</script>
</body>
</html>