Skip to content

Instantly share code, notes, and snippets.

@hornc
Last active November 21, 2018 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hornc/fc0477e7a3321485ef16b4d7c0cd9f38 to your computer and use it in GitHub Desktop.
Save hornc/fc0477e7a3321485ef16b4d7c0cd9f38 to your computer and use it in GitHub Desktop.
Brainfoctal Interpreter
#!/bin/bash
# Brainfoctal interpreter.
# REQUIREMENTS:
# python3 to convert
# bff4, http://mazonka.com/brainf/bff4.c to interpret,
# $BFI should point to the compiled interpreter
# USAGE:
# ./bf8 <bf8 Gödel number in dec|oct|hex|bin> <input data>
# EX.
# ./bf8 0o6565 Hi
# ./bf8 0xd75 Hi
BFI=./bff4
BF="]><+-.,["
BF8PY="""s=oct(int(\"$1\", 0))[2:]
for i,c in enumerate(\"$BF\"):s=s.replace(str(i),c)
print(s)"""
conv=$(python3 -c "$BF8PY");echo $conv
if [ -e $BFI ];then $BFI <<<$conv\!$2;echo;fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment