-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathindex.html
74 lines (62 loc) · 2.03 KB
/
index.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>evalfilter experiment</title>
</head>
<body>
<script src="wasm_exec.js"></script>
<script>
if (!WebAssembly.instantiateStreaming) {
// polyfill
WebAssembly.instantiateStreaming = async (resp, importObject) => {
const source = await (await resp).arrayBuffer();
return await WebAssembly.instantiate(source, importObject);
};
}
const go = new Go();
let mod, inst;
WebAssembly.instantiateStreaming(fetch("lib.wasm"), go.importObject).then(
async result => {
mod = result.module;
inst = result.instance;
await go.run(inst);
}
);
</script>
<h2>evalfilter</h2>
<p>This is a simple demo which allows you to play with <a href="https://github.com/skx/evalfilter/">evalfilter</a> syntax :)</p>
<p>Everything you expect <i>should</i> work as you'd expect; note that the <tt>print</tt> and <tt>printf</tt> functions have been reimplemented to output to the console here.</p>
<table width="100%" border="1">
<tr valign="top"><td align="right" width="80%">
<textarea style="width:100%;" rows="20" cols="50" id="input">
print( "I'm running code\n" );
// String + Array for experimenting with
Author = "Alice";
names = [ "Alice", "Bob", "Homer" ];
// Show some output
foreach value in 0..5 {
print( "Number ", value, "\n");
}
// If the string is in the array ..
if ( Author in names ) {
return "I found myself";
}
// If the length is good ..
if ( len( Author ) == 3 ) {
return true;
}
// If we have lower-case
if ( Author == lower(Author) ) {
return "Case doesn't exist; class doesn't exist.";
}
return "bored now";
</textarea>
</td><td align="left" width="20%">
<button onClick="run('input', 'result');" id="run">Run</button>
</td></tr>
<tr><td colspan="2">
<textarea style="width:100%;" rows="15" cols="80" id="result"></textarea>
</td></tr></table>
</body>
</html>