Created
January 19, 2017 15:26
-
-
Save kuwa72/5f48d94b05c0e850922d305b44e7235a to your computer and use it in GitHub Desktop.
One line brainfuck compiler
This file contains 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
{grep -o . | (echo '{ ptr=1;memory=() ';awk '/\[/{print "while [[ memory[$ptr] -ne 0 ]];do"} /\]/{print "done;"}/\+/{print "let $((memory[$ptr]++));"} /-/{print "let $((memory[$ptr]--));"} />/{print "let $((ptr++));"} /</{print "let $((ptr--));"} /\./{print "printf \"\\x$(printf %x $((memory[$ptr])))\";"} /,/{print "memory[$ptr]=$(head -c 1);"}';echo '}') | sh} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
optimizer for @kou029w implementation.