Advertisement
john9912

brainfuck to Lua --- Minified

Jul 9th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. arg={...}readfile=fs.open(arg[2],"r")B=readfile.readAll()readfile.close()file=fs.open(arg[1],"w")D={}j=1;repeat D[j]=B:sub(j,j)j=j+1 until j==#B+1;function parse(a)if D[a]~=nil then return D[a]else file.close()error("DONE!")end end;T={}T["<"]="p = p - 1"T[">"]="p = p + 1"T["+"]="a[p] = a[p] or 0\na[p] = a[p] + 1"T["-"]="a[p] = a[p] or 0\na[p] = a[p] - 1"T["."]="print(a[p] or 0)"T[","]="a[p] = read()"T["["]="a[p] = a[p] or 0\nwhile a[p] ~= 0 do"T["]"]="end"function translate(b)if T[b]then return T[b]end;return"--Inv.char"end;function writeFile(c)file.writeLine(translate(parse(c)))end;file.writeLine("local a = {}\nlocal p = 1\nlocal i = 1\n--repeat\n--a[i] = 0\n--i = i + 1\n--until i == 16384")local d=1;while true do writeFile(d)d=d+1 end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement