forked from biwascheme/biwascheme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
repl.html.orig
133 lines (125 loc) · 3.59 KB
/
repl.html.orig
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>BiwaScheme REPL</title>
<style type="text/css">
div#bs-repl{
border:1px solid black;
padding:1em;
width:100%;
}
div#bs-console{
border:1px solid black;
padding:1em;
margin-top:1em;
}
div#bs-opecode{
border:1px solid black;
padding:1em;
margin-top:1em;
}
span.dump_opecode{ color:orange; }
span.dump_constant{ color:red; }
div.bs-snippet{
white-space:pre;
cursor:pointer;
}
div.bs-snippet:hover {
white-space:pre;
cursor:pointer;
background-color:darkseagreen;
}
</style>
</head>
<body>
<h1><a href='http://www.biwascheme.org/'>BiwaScheme</a> REPL</h1>
<!--<button id="test">foo</button>-->
<div id="bs-repl">
<table><tr><td valign="top">
<form>
<textarea id="bs-input" rows="10" cols="60">(print "Hello, world!")</textarea><br>
<div style="float:right;">
<span id="time"></span>
<input type="button" value="eval" onclick="bs_eval()">
</div>
<br style="clear:both"/>
</form>
<div id="bs-console">
</div>
<div id="bs-opecode">
</div>
</td>
<td valign="top">
<div id="bs-sample">
<h2>Sample</h2>
<ul>
<li><div class="bs-snippet">(+ 1 2)</div></li>
<li><div class="bs-snippet">(not #t) </div></li>
<li><div class="bs-snippet">(boolean=? #t #t #t) </div></li>
<li><div class="bs-snippet">;; length by Y combinator
(((lambda (f)
((lambda (proc) (f (lambda (arg) ((proc proc) arg))))
(lambda (proc) (f (lambda (arg) ((proc proc) arg))))))
(lambda (self)
(lambda (ls)
(if (null? ls) 0 (+ 1 (self (cdr ls)))))))
'(1 2 3 4 5))
</div></li>
<li><div class="bs-snippet">;; length by Y combinator (tail recursive)
(((lambda (f)
((lambda (proc) (f (lambda (arg1 arg2) ((proc proc) arg1 arg2))))
(lambda (proc) (f (lambda (arg1 arg2) ((proc proc) arg1 arg2))))))
(lambda (self)
(lambda (ls acc)
(if (null? ls) acc (self (cdr ls) (+ 1 acc))))))
'(1 2 3 4 5) 0)
</div></li>
</ul>
</div>
</td></tr></table>
</div>
<script type="text/javascript" src="src/development_loader.js">// <![CDATA[
var on_error = function(e){
puts(e.message);
throw(e);
};
var biwascheme = new BiwaScheme.Interpreter(on_error);
function bs_eval(){
$("#bs-console").empty();
var str = $("#bs-input").val();
var opc = biwascheme.compile(str);
var dump = (new BiwaScheme.Dumper()).dump_opc(opc);
$("#bs-opecode").html(dump);
var before = new Date();
biwascheme.evaluate(str, function(result){
var after = new Date();
$("#time").html("Time: " + (after-before)/1000 + "sec");
puts(BiwaScheme.to_write(result));
});
<<<<<<< HEAD
try{
var opc = biwascheme.compile(str);
$('bs-opecode').innerHTML = (new BiwaScheme.Dumper()).dump_opc(opc);
var before = new Date();
biwascheme.evaluate(str, function(result){
var after = new Date();
$('time').innerHTML = "Time: " + (after-before)/1000 + "sec";
BiwaScheme.Port.current_output.put_string(BiwaScheme.to_write(result));
});
}
catch(e){
BiwaScheme.Port.current_output.put_string(e.message);
throw(e);
}
=======
>>>>>>> 1e7b93a4d2ebd12f1e3363f702aa04d26561f537
return false;
}
$(".bs-snippet").click(function(e){
$("#bs-input").html($(this).html());
});
// ]]></script>
</body>
</html>
<!-- vim:set ft=javascript: -->