Skip to content

Instantly share code, notes, and snippets.

@lutoma
Created June 14, 2012 10:38
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 lutoma/2929518 to your computer and use it in GitHub Desktop.
Save lutoma/2929518 to your computer and use it in GitHub Desktop.
Converts Brainfuck code from stdin to C on stdout (Compile with GCC or similar)
x='char';p,s=(print,{'>':'++p;','<':'--p;','+':'++*p;','-':'--*p;','.':'put'+x+'(*p);',',':'*p=get'+x+'();','[':'for(;*p;){',']':'}'});l=(x+' a[0x'+'f'*4+'];'+x+'*p=a;int main(){',[s[c]for(c)in __import__('os').fdopen(0).read()if(c)in s],'}');[[p(z) for z in i]if type(i)is(list)else p(i)for(i)in l]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment