git @ Cat's Eye Technologies ZOWIE / 5209705
Add demo of running zowie.py under Skulpt. catseye 8 years ago
2 changed file(s) with 70 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
0 <!DOCTYPE html>
1 <html>
2 <!-- adapted from https://gist.github.com/bnmnetp/4650616 -->
3 <head>
4 <meta charset="utf-8">
5 <script src="http://catseye.tc/contrib/skulpt/skulpt.min.js" type="text/javascript"></script>
6 <script src="http://catseye.tc/contrib/skulpt/skulpt-stdlib.js" type="text/javascript"></script>
7 <script type="text/javascript">
8 function outf(text) {
9 var mypre = document.getElementById("output");
10 mypre.innerHTML = mypre.innerHTML + text.replace(/\n$/, "");
11 }
12 function builtinRead(x) {
13 if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined) {
14 throw "File not found: '" + x + "'";
15 }
16 return Sk.builtinFiles["files"][x];
17 }
18 function runit() {
19 var pyprog = document.getElementById("yourcode").value;
20 var esoprog = document.getElementById("esocode").value;
21 var mypre = document.getElementById("output");
22 mypre.innerHTML = '';
23 Sk.canvas = "mycanvas";
24 Sk.pre = "output";
25 Sk.configure({output: outf, read: builtinRead});
26 prog = pyprog + "\n";
27 prog += 'p = Processor()\n';
28 prog += 'p.load_string("""\n';
29 prog += esoprog;
30 prog += '""")\n';
31 prog += 'p.run()\n';
32 eval(Sk.importMainWithBody("<stdin>", false, prog));
33 }
34 </script>
35 </head>
36
37 <body>
38 <h1>ZOWIE</h1>
39
40 <textarea id="yourcode" cols="80" rows="10">
41 # paste zowie.py here
42 </textarea><br/>
43
44 <textarea id="esocode" cols="80" rows="10">
45 ; Display the Roman alphabet in reverse, in ZOWIE
46 ; This example source is in the public domain.
47
48 MOV R10, 90 ; initially it's "Z"
49 MOV R1, R1 ; BEGIN TRANSACTION for "REPEAT"
50 MOV R0, R10 ; output character
51 MOV R8, R10 ; decrement character
52 MOV R5, 1
53 MOV R10, R8
54 MOV R8, R10 ; test if character is above "@"
55 MOV R5, 64
56 MOV R3, R8 ; COMMIT AND REPEAT if non-zero
57 </textarea><br/>
58
59 <button type="button" onclick="runit()">Run</button>
60
61 <pre style="border: 1px solid blue" id="output"></pre>
62 </body>
63
64 </html>
11 #
22 # zowie.py -- Interpreter for the ZOWIE language
33 # Chris Pressey, Cat's Eye Technologies, Oct 6 2009
4 # Adapted to run under Skulpt Oct 10 2013
45 # This source code is in the public domain.
5 #
6 # $Id: zowie.py 298 2009-12-29 17:47:45Z cpressey $
76 #
87
98 import re
1312 # check if running under Skulpt, and if so, apply appropriate modifications
1413 if getattr(sys, 'resetTimeout', None) is not None:
1514 __name__ = '__skulpt__'
15
1616 class EOFError:
1717 pass
18
1819 class SyntaxError:
1920 pass
21
2022 class UnicodeEncodeError:
2123 pass
24
2225 def output(code):
2326 if code > 126:
2427 print "&#%d;" % code