感嘆しかつ簡単だったので。
プログラム言語「てってってー」 - H.Hiroのチラシの裏の裏Brainf*ckのパクリですが、若干拡張仕様があります。
- ベースは
- 拡張仕様(ー〜てー)がなければ素直にてってってー → Br@inf.ck → JavaScript ですんだのだけど。
- コメント処理など、あまりてってってー的でないところもあります。
- BF Source
- 入力
- 出力
-
- 実行時間
- Compiled てってってー
Unlambdaから「ののワさん」とか「まっすぐ」を何言語からひねりだすとかは各自の宿題とします。
Dan the Br@infu.ker
function Tettettee(str){ this.code = []; this.output = []; this.input = []; this.pc = this.sp = 0; this.debug = 0; this.js = ''; this.timer = 0; this.init = function(str){ str = str.replace(/[ ]*\{[^\}]+\}/g, ''); str = str.replace(/(ー.*?てー|ててー|てっー|てってー|てっててー|てってっー|てってってー|てってっててー|てってってっー)/g, function(c){ switch (c) { case 'てってー' : return 'sp++;\n'; case 'てっててー' : return 'sp--;\n'; case 'ててー' : return 'data[sp]++;\n'; case 'てっー' : return 'data[sp]--;\n'; case 'てってっー' : return 'output.push(data[sp++]);\n'; case 'てってってー' : return 'data[sp++]=input.shift();\n'; case 'てってっててー' : return 'while(data[sp]){\n'; case 'てってってっー' : return '}\n'; default: return 'for(var j = 1; j < \'' + c + '\'.length-2; j++)' + 'data[sp++] = \'' + c + '\'.charCodeAt(j);\n'; }; }); str = 'var data = [];\nvar output = [];\nvar sp = 0;\n' + 'for(var i = 0; i < 65536; i++) data.push(0);\n' + str + 'return output;\n'; try{ // this.code = eval(str); this.js = this.code = new Function('input', str); } catch(e){ alert(e + "\n" + str); } this.input = []; }; this.stdin = function(str){ for (var i = 0; i < str.length; i++){ this.input.push(str.charCodeAt(i)); } }; this.stdout = function(){ var str = ''; for (var i = 0; i < this.output.length; i++){ str += String.fromCharCode(this.output[i]); } return str; }; this.run = function(){ var start = (new Date()).getTime(); this.output = this.code(this.input); this.timer = ((new Date()).getTime() - start)/1000; } this.init(str); }
「てってってーてってっててー」になってしまうんですけど、
ブラウザのせいでしょうか?(Safari)