Created
December 26, 2016 16:26
-
-
Save DonaldKellett/f05e27814b1a51284d16a407d85a7ce7 to your computer and use it in GitHub Desktop.
Converts Brainfuck code into Boolfuck code with no optimizations performed. All non-command characters are removed.
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
function brainfuckToBoolfuck(brainfuck) { | |
return brainfuck.replace(/[^+\-.,<>\[\]]/g, "").split("").map(command => ({ | |
"+": ">[>]+<[+<]>>>>>>>>>[+]<<<<<<<<<", | |
"-": ">>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+]<<<<<<<<<", | |
"<": "<<<<<<<<<", | |
">": ">>>>>>>>>", | |
",": ">,>,>,>,>,>,>,>,<<<<<<<<", | |
".": ">;>;>;>;>;>;>;>;<<<<<<<<", | |
"[": ">>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>[+<<<<<<<<[>]+<[+<]", | |
"]": ">>>>>>>>>+<<<<<<<<+[>+]<[<]>>>>>>>>>]<[+<]" | |
})[command]).join(""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment