Braindamage is a NEW scripting language that makes Brainfuck even more Brainfuckier!
bd runs Braindamage scripts.
bdc converts Brainfuck scripts to the clearly superior alternative.
For now, you need to run Lua on a UNIX-like operating system.
Braindamage is a NEW scripting language that makes Brainfuck even more Brainfuckier!
bd runs Braindamage scripts.
bdc converts Brainfuck scripts to the clearly superior alternative.
For now, you need to run Lua on a UNIX-like operating system.
#!/usr/bin/env lua | |
if not arg[1] then | |
print("No input file specified!") | |
os.exit(1) | |
end | |
local tableInsert,tableConcat,ioOpen,osExecute,osRemove = table.insert,table.concat,io.open,os.execute,os.remove | |
local fhand,ferr = ioOpen(arg[1], "r") | |
if not fhand then | |
print(ferr) | |
os.exit(1) | |
end | |
fcont = fhand:read("*all") | |
fhand:close() | |
local i = 0 | |
local out = {} | |
for n=1,#fcont do | |
local part = fcont:sub(n,n) | |
if part == " " then | |
i = i + 1 | |
elseif part == "\n" then | |
tableInsert(out, string.char(i)) | |
i = 0 | |
else | |
print("Malformed Braindamage script!") | |
end | |
end | |
local fhand = ioOpen("/tmp/bdtmp", "w") | |
fhand:write(tableConcat(out)) | |
fhand:close() | |
osExecute("bf /tmp/bdtmp") | |
osRemove("/tmp/bdtmp") |
#!/usr/bin/env lua | |
if not arg[1] then | |
print("No input file specified!") | |
os.exit(1) | |
end | |
if not arg[2] then | |
print("No output file specified!") | |
os.exit(1) | |
end | |
local tableInsert,tableConcat,ioOpen,stringByte,stringRep = table.insert,table.concat,io.open,string.byte,string.rep | |
local fhand,ferr = ioOpen(arg[1], "r") | |
if not fhand then | |
print(ferr) | |
os.exit(1) | |
end | |
fcont = fhand:read("*all") | |
fhand:close() | |
local i = 0 | |
local out = {} | |
for n=1,#fcont do | |
tableInsert(out, stringRep(" ",stringByte(fcont:sub(n,n))).."\n") | |
end | |
local fhand,ferr = ioOpen(arg[2], "w") | |
if not fhand then | |
print(ferr) | |
os.exit(1) | |
end | |
fcont = fhand:write(tableConcat(out)) | |
fhand:close() |
I am aware how ugly it's programmed at the moment, but I whipped it up in 10 minutes.
I'm lazy.