1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta content=
"text/html; charset=utf-8" http-equiv=
"Content-Type"/>
6 <link rel=
"stylesheet" href=
"style/pixelless.css" type=
"text/css"/>
7 <script type=
"text/javascript" src=
"script/util.js"></script>
8 <title>Brainfuck
</title>
12 <div class=
"content header">
17 <p><a href=
"http://en.wikipedia.org/wiki/Brainfuck">Brainfuck
</a> "IDE"</p>
18 <a href=
"#" onclick=
"run(); return false;" id=
"runit" style=
"text-decoration: none">▶ Run
</a><br/>
20 <pre>Clear:
<a href=
"javascript:add(this)" onclick=
"add(this); return false;">[-]
</a> Clear prev no zero:
<a
21 href=
"javascript:add(this)" onclick=
"add(this); return false;">[[-]
<]
</a>
22 Rewind:
<a href=
"javascript:add(this)" onclick=
"add(this); return false;">[
<]
></a> Fast-forward:
<a
23 href=
"javascript:add(this)" onclick=
"add(this); return false;">[
>]
<</a>
24 Cat:
<a href=
"javascript:add(this)" onclick=
"add(this); return false;">,[.,]
</a> Moving the pointer:
<a
25 href=
"javascript:add(this)" onclick=
"add(this); return false;">>,[.
>,]
</a>
26 Add:
<a href=
"javascript:add(this)" onclick=
"add(this); return false;">[-
>+
<]
</a> or
<a
27 href=
"javascript:add(this)" onclick=
"add(this); return false;">[-
>+
>+
<<]
>>[-
<<+
>>]
</a> Copy:
<a
28 href=
"javascript:add(this)" onclick=
"add(this); return false;">[-]
>[-]
<<[-
>+
>+
<<]
>>[-
<<+
>>]
</a></pre>
31 <div id=
"memory" style=
"float:right"></div>
32 <div id=
"hint" style=
"clear: right; float:right">
39 [ if data is zero jump after matching ]
<br/>
40 ] id data is not zero goto matching [
<br/>
42 <label>Input:
<input type=
"text" id=
"input" value=
"" style=
"margin-bottom: .2em; font-family:monospace; width:80ex"/></label><br/>
43 <textarea id=
"edit" cols=
"80" rows=
"14"></textarea>
44 <textarea id=
"out" cols=
"80" rows=
"6" readonly=
"readonly"></textarea>
52 <script type=
"text/javascript" language=
"JavaScript">
53 var memoryLimit =
30000;
54 var execLimit =
10000;
58 var target = document.getElementById('edit');
59 var x = target.selectionStart;
60 var value = obj.innerHTML.replace(/
</g,
"<").replace(/
>/g,
">");
61 var before = target.value.substring(
0, x);
62 var after = target.value.substr(target.selectionEnd);
63 target.value = before + value + after;
64 target.selectionStart = x + value.length;
65 target.selectionEnd = x + value.length;
73 var x = (memory[addr] ||
0) + n;
82 var r = input[inpos++];
83 if (r === undefined) return
0; // EOF
84 return r.charCodeAt(
0);
88 var input = document.getElementById('input').value;
89 var src = document.getElementById('edit').value;
102 var i = -
1, n = src.length;
115 var loop = loopstack.pop();
117 if (loop === undefined)
118 throw new Error(['Loop brace mismatch at line', line, ', column', column].join(' '));
139 if (++steps
> execLimit)
140 throw new Error(['Execution limit of ', execLimit, ' cycles exceded at line ', line, ', column', column].join(' '));
153 throw new Error(['Address underrun at line', line, ', column', column].join(' '));
158 if (++addr
> memoryLimit)
159 throw new Error(['Address overrun at line', line, ', column', column].join(' '));
180 i = loops.indexOf(i);
182 throw new Error(['Unxepected loop error at line', line, ', column', column].join(' '));
188 if (memory[addr] <
32)
189 out += memory[addr].toString() + ' ';
191 out += String.fromCharCode(memory[addr]);
196 memory[addr] = get_input();
202 document.getElementById('memory').innerHTML = memory.map(function(x, n) {
203 if (n == addr)return '
<u>' + x + '
</u>'; else return x;
205 document.getElementById('out').value = out;