Last active
March 3, 2017 01:57
-
-
Save mov37/670c4727b18a2c767aeb9874cea390bd to your computer and use it in GitHub Desktop.
a 430byte brainfuck interpreter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p=process;j=require('path').join;r=require('fs').readFileSync;u='utf8';d=__dirname;v=p.argv;e=[];i=v[3]?r(j(d,v[3]),u).split(''):[];s=r(j(d,v[2]),u);t={'<':'c--;','>':'c++;','+':'m[c]++;','-':'m[c]--;',',':'i[0]&&(m[c]=i.shift().charCodeAt(0)%0xFF);','.':'p.stdout.write(String.fromCharCode(m[c]));','[':'while(m[c]){',']':'}'};m=new Array(0xFFFF).fill(c=0);for(n of s.replace(/[^<>\-+,.[\]]/g,''))e.push(t[n]);eval(e.join('')); |
Author
mov37
commented
Mar 3, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment