3
\$\begingroup\$

Input:

Any Brainfuck program. This includes brainfuck programs with comments such as +++COMMENT[>+++<-]..

Output:

A program in one of the below languages that produces the same output as the Brainfuck program on all inputs. It should produce the same output exactly as the interepreter on this website There are no or performance restrictions on the output program; the outputted program doesn't need to be optimized in any way. In other words, the quality of the outputted program does not affect score, only the translation program. To clarify: you may write your answer in any language that is normally valid for answers on PCG. The restriction on output languages is only for the outputted program.

The outputted program only receives the same input that would be received by the Brainfuck program. The outputted program does not receive the Brainfuck program as input.

Valid Output Languages

  • C#
  • C++
  • C
  • Java 8
  • Javascript ES6 (it is both okay to receive all of stdin in a single prompt, or multiple prompts per character)
  • Perl
  • Python 2.7
  • Python 3.4.2
  • Ruby

Fine Print

You may write a program or function which takes the Brainfuck program as a String argument or on STDIN or closest alternative, and which returns the output as a String or printing it to STDOUT (or closest alternative). You may optionally include a single trailing newline in the output.

Additionally, standard loopholes which are no longer funny are banned. You may not use external libraries or external data files, the code must be self contained.

This is , shortest program wins.

\$\endgroup\$
  • \$\begingroup\$ possible duplicate of Interpret Brainfuck \$\endgroup\$ – mbomb007 May 12 '15 at 21:24
  • 2
    \$\begingroup\$ It's not a dup, as a compiler is not an interpreter \$\endgroup\$ – edc65 May 12 '15 at 21:39
  • \$\begingroup\$ It might not be a dup, but the question is whether there is a shorter solution than copy&pasting a golfed interpreter in one of the allowed languages; and copying the brainfuck to the output program. \$\endgroup\$ – blutorange May 12 '15 at 22:18
  • 3
    \$\begingroup\$ Can you clarify the behavior of the linked interpreter? What is the max number of memory cells? How is overflow of cell values handled? \$\endgroup\$ – nderscore May 12 '15 at 22:27
  • 1
    \$\begingroup\$ @nderscore The linked interpreter uses signed integers that wrap around from -128 to +127. However, the values are effectively cast to 2-byte unsigned ints before being output as characters; so -1 => chr(65535) (). Personally, I would prefer output in the form of 1-byte (ASCII) characters (in part because that's what my solution uses). The tape is circular, with 32768 cells. durron597, are these specs what you intended? \$\endgroup\$ – DLosc May 13 '15 at 6:25
5
\$\begingroup\$

K, 143 129 bytes

1!"}int a[99];int*p=a;main(){",,/{("p++;";"p--;";"*p++;";"*p--;";"*p=getchar();if(*p<0)*p=0;";"putchar(*p);";"while(*p){";"}";"")"><+-,.[]"?x}'

This is an extremely straightforward approach which generates C source code by emitting a preamble, a C snippet for each BF command and then a postscript. Non-BF characters are translated into empty strings in the concatenated output.

The translation into C is as follows:

  • preamble: int a[99];int*p=a;main(){
  • >: p++;
  • <: p--;
  • +: *p++;
  • -: *p--;
  • ,: *p=getchar();if(*p<0)*p=0;
  • .: putchar(*p);
  • [: while(*p){
  • ]: }
  • postscript: }

I suspect that there is room for improvement here by using more mangled abuses of C or compressing the C fragments.

The K part of the program by itself would look like the following, where c is the C translations of each BF instruction and p is the preamble/postscript:

1!p,,/{c"><+-,.[]"?x}'

Using the venerable BF string reverser program >,[>,]<[.<] as my test case I generate code which looks like the following after a bit of whitespace for readability:

int a[99];
int*p=a;

main(){
    p++;
    *p=getchar();if(*p<0)*p=0;
    while(*p){
        p++;
        *p=getchar();if(*p<0)*p=0;
    }
    p--;
    while(*p){
        putchar(*p);
        p--;
    }
}

edit:

A few tweaks. Firstly, more compliant tape declaration as suggested by alexander-brett. The int part can be left off:

int a[99]; -> a[1<<15]; (-1 byte)

Also, it seems that EOF behavior in BF can return 0, -1 or cause no change as a result of ,. EOF=-1 seems to be what other solutions are going with, so for the sake of uniformity I will do the same:

*p=getchar();if(*p<0)*p=0; -> *p=getchar(); (-13 bytes)

Note that this means my string reverser program will choke if you simply cat it a file ending in EOF(!), but as above it seems to be fair.

The new complete 129 byte solution:

1!"}a[1<<15];int*p=a;main(){",,/{("p++;";"p--;";"*p++;";"*p--;";"*p=getchar();";"putchar(*p);";"while(*p){";"}";"")"><+-,.[]"?x}'
\$\endgroup\$
  • \$\begingroup\$ Shouldn't that be a[30000]? \$\endgroup\$ – alexander-brett May 13 '15 at 6:51
  • \$\begingroup\$ That would be more compliant. a[1<<15] is closer to the interpreter above, and I can leave off "int" as C variables are implicitly ints. It also looks like my "EOF=0" handling is more than is strictly necessary, even if it's a common assumption. \$\endgroup\$ – JohnE May 13 '15 at 14:02
  • 1
    \$\begingroup\$ DARN! You beat me to K. :) \$\endgroup\$ – kirbyfan64sos May 29 '15 at 19:19
4
\$\begingroup\$

Javascript (ES7 Draft), 170 bytes

Function which compiles BF source code into Javascript. The resulting code accepts input via prompt() and outputs via alert(), both one character at a time.

f=x=>'x=[i=0];'+[for(y of x)'z=x[i]|=0,x[i]'+'0++0--0,i++0,i--0,alert(String.fromCharCode(z))0=prompt().charCodeAt()0;for(;x[i];){x0}x'.split(0)['+-><.,[]'.indexOf(y)+1]]

The result is composed of:

Preamble: x=[i=0]; - Initializes x as an object to store memory cells and i as 0 for the initial index.

Each command is prefixed with: z=x[i]|=0,x[i] - Forces undefined memory cells to 0, starts all commands with x[i] to reduce repetition in the translation map. Stores value at current index in z.

Each command is also seperated by , commas due to implicit casting of the array to a string.

Command translation map:

  • (unknown) => empty string
  • + => ++ - increment value at x[i]
  • - => -- - decrement value at x[i]
  • > => ,i++ - increment index pointer i
  • < => ,i-- - decrement index pointer i
  • . => ,alert(String.fromCharCode(z)) - alert character from value at x[i]
  • , => =prompt().charCodeAt() - store converted character code from prompt at x[i]
  • [ => ;for(;x[i];){x - Loop while value at x[i] is truthy (non-zero).
  • ] => }x - End loop. Unused x appended to prevent errors from commas.
\$\endgroup\$
4
\$\begingroup\$

Python 2, 250 244 bytes

def B(b):
 I=0;print"from ctypes import*;R,p,c=[0]*9999,0,CDLL('libc.so.6')"
 for c in b:
     try:print' '*I+'p+=1|p-=1|R[p]+=1|R[p]-=1|c.putchar(R[p])|R[p]=c.getchar()|while R[p]!=0:|'.split('|')['><+-.,[]'.index(c)];I+=']&['.index(c)-1
     except:0

#first indentation level=space, 2nd indentation level=tab

(thks to @undergroundmonorail for helping me save 4 extra bytes)

The B function takes bf code as parameter and generates... a Python script.

Brainfuck's "tape" is seen a an array called R, which owns 32768 9999 items, and the pointer is stored in a variable called p.

The lack of a native equivalent to C's getchar function in python forced me to load it using ctypes at runtime, which makes the generated script unusable on Windows (untested, I guess that a Windows version should load mscvrt.dll instead of libc.so.6)

Example

The infamous 'hello world':

B('++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.')

Generates the following script:

from ctypes import*;R,p,c=[0]*9999,0,CDLL('libc.so.6')
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
while R[p]!=0:
 p+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 p+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 p+=1
 R[p]+=1
 R[p]+=1
 R[p]+=1
 p+=1
 R[p]+=1
 p-=1
 p-=1
 p-=1
 p-=1
 R[p]-=1

p+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
p+=1
R[p]+=1
c.putchar(R[p])
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
c.putchar(R[p])
R[p]+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
p+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
p-=1
p-=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
p+=1
c.putchar(R[p])
R[p]+=1
R[p]+=1
R[p]+=1
c.putchar(R[p])
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
c.putchar(R[p])
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
R[p]-=1
c.putchar(R[p])
p+=1
R[p]+=1
c.putchar(R[p])
p+=1
c.putchar(R[p])
\$\endgroup\$
  • \$\begingroup\$ Unless I'm mistaken, the length of R is 0xfff=4095, not 32768. Also you can save some bytes by changing the last line to except:0. 0 is a no-op and 3 bytes shorter than pass. \$\endgroup\$ – undergroundmonorail May 28 '15 at 14:11
  • \$\begingroup\$ @undergroundmonorail en.wikipedia.org/wiki/Brainfuck#Array_size \$\endgroup\$ – Kade May 29 '15 at 1:49
  • \$\begingroup\$ You can save a few bytes by replacing from ctypes import* with from msvcrt import* and using just putchar instead of c.putchar. \$\endgroup\$ – pppery Jul 16 '17 at 16:19
2
\$\begingroup\$

Perl, 127 120B + 2

%h=qw#> ++p;
< --p;
+ ++*p;
- --*p;
. putchar(*p);
, *p=getchar();
[ while(*p){
] }#;say"a[1<<15],*p=a;main(){@h{/./g}}"

The magic happens in @h{/./g}: /./g splits the input into characters, @h{} is a hash slice, and the "" interpolation joins hash elements using a space (by default). The target is C using exactly the spec on the Brainfuck website. 2 point penalty for -0n: run with

perl -M5.10.0 -0n scratch.pl > test.c < input.bf && gcc -ansi test.c && ./a.out

7B saving thanks to CL- and the prevailing opinion on variable declarations.

\$\endgroup\$
  • \$\begingroup\$ It looks like you can shorten the C preamble from main(){int a[1<<15];int*p=a; to a[1<<15],*p=a;main(){ for a 7 byte saving. This also guarantees that each element of a will be initialised to 0. \$\endgroup\$ – CL- May 14 '15 at 16:58
  • \$\begingroup\$ @CL- how do I compile that? gcc on OSX errors if I don't put a type in \$\endgroup\$ – alexander-brett May 14 '15 at 17:11
  • \$\begingroup\$ You'll see a warning, but it should still compile fine. \$\endgroup\$ – JohnE May 15 '15 at 13:48
1
\$\begingroup\$

Common Lisp & JavaScript - 425 bytes

N.B. I am using the Parenscript library, so this is just for the fun.

(defun b(i &aux(s(coerce i'list)))(labels((c()(do(r x)((or x(not s))(reverse r))(push(case(pop s)(#\>`(incf p))(#\<`(decf p))(#\+`(setf(aref a p)(1+#1=(or(aref a p)0))))(#\-`(setf(aref a p)(1- #1#)))(#\.`((ps:@ console log)((ps:@ *String from-char-code)#1#)))(#\,`(setf(aref a p)((ps:@(prompt)char-code-at)0)))(#\[`(loop until(= 0 #1#)do ,@(c))))(#\](setf x t)(go /))(t(go /)))r)/)))(ps:ps*`(let((a(make-array))(p 0)),@(c)))))

Ungolfed

(defun bf(i)
  (let ((s (coerce i'list)))
    (labels((lbf ()
              (do(r x)((or x(not s))(reverse r))
                      (push (case (pop s)
                              (#\> `(incf p))
                              (#\< `(decf p))
                              (#\+ `(setf(aref a p)(1+(or (aref a p)0))))
                              (#\- `(setf(aref a p)(1-(or (aref a p)0))))
                              (#\. `((ps:@ console log)((ps:@ *String from-char-code) (or(aref a p)0))))
                              (#\, `(setf(aref a p) ((ps:@ (prompt) char-code-at) 0)))
                              (#\[ `(loop until(= 0(or(aref a p)0))do ,@(lbf)))
                              (#\] (setf x t) (go /))
                              (t (go /)))
                            r)/)))
      `(let ((a (make-array))
             (p 0))
         ,@(lbf)))))

Explanations

  • Convert input string as list of characters s
  • The recursive function lbf pop elements from s and build a local list of expressions r
  • Whenever we encounter a [ character, the function recurse in order to create a nested block of instructions
  • Whenever we encounter a ] character, the function exits, returning to one higher level of invocation. Note that when returning from the function, the variable s has been modified to hold the rest of the characters to be processed, thanks to pop.
  • The whole S-expr being built is expressed in a sub-language of Common Lisp that can be converted to Javascript thanks to Parenscript.

Optimized version

I made a slightly optimized version that is too long to post here, with the following changes:

  • Parsing only produces an AST containing the following symbols: print, read, left, right, inc, dec, bracketed (nested tree) and brainfuck (root tree).

  • The AST is analyzed to group all increment and decrement operations, as well as move operations, in order to build (add x) and (move y) terms.

  • Finally, the AST is converted into Parenscript code.

  • That code is emitted as a Javascript string

The resulting Javascript for Hello World is:

(function () {
   var a = new Array();
   var p = 0;
   a[p] = (a[p] || 0) + 10;
   while (0 !== (a[p] || 0)) {
       ++p;
       a[p] = (a[p] || 0) + 7;
       ++p;
       a[p] = (a[p] || 0) + 10;
       ++p;
       a[p] = (a[p] || 0) + 3;
       ++p;
       a[p] = (a[p] || 0) + 1;
       p += -4;
       a[p] = (a[p] || 0) + -1;
   };
   ++p;
   a[p] = (a[p] || 0) + 2;
   console.log(String.fromCharCode(a[p] || 0));
   ++p;
   a[p] = (a[p] || 0) + 1;
   console.log(String.fromCharCode(a[p] || 0));
   a[p] = (a[p] || 0) + 7;
   console.log(String.fromCharCode(a[p] || 0));
   console.log(String.fromCharCode(a[p] || 0));
   a[p] = (a[p] || 0) + 3;
   console.log(String.fromCharCode(a[p] || 0));
   ++p;
   a[p] = (a[p] || 0) + 2;
   console.log(String.fromCharCode(a[p] || 0));
   p += -2;
   a[p] = (a[p] || 0) + 15;
   console.log(String.fromCharCode(a[p] || 0));
   ++p;
   console.log(String.fromCharCode(a[p] || 0));
   a[p] = (a[p] || 0) + 3;
   console.log(String.fromCharCode(a[p] || 0));
   a[p] = (a[p] || 0) + -6;
   console.log(String.fromCharCode(a[p] || 0));
   a[p] = (a[p] || 0) + -8;
   console.log(String.fromCharCode(a[p] || 0));
   ++p;
   a[p] = (a[p] || 0) + 1;
   console.log(String.fromCharCode(a[p] || 0));
   ++p;
   return console.log(String.fromCharCode(a[p] || 0));
})();
\$\endgroup\$
1
\$\begingroup\$

rs, 214 bytes

Outputs Ruby 1.9 code.

[^+\-[\]<>.,]/
\[/while tape[i
\]/end;
\[i/[i] != 0 do 
\./print tape[i].chr;
if !defined?tape then require "io\x2Fconsole";tape=[0]*9999;i=0;end;
\+/tape[i]+=1;
-/tape[i]-=1;
</i+=1;
>/i-=1;
,/tape[i]=STDIN.getch;

Try it here!

Sample runs

Hello, world!

Input:

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.

Output:

if !defined?tape then require "io\x2Fconsole";tape=[0]*9999;i=0;end;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;while tape[i] != 0 do i-=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;while tape[i] != 0 do i-=1;tape[i]+=1;tape[i]+=1;i-=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;i-=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;i-=1;tape[i]+=1;i+=1;i+=1;i+=1;i+=1;tape[i]-=1;end;i-=1;tape[i]+=1;i-=1;tape[i]+=1;i-=1;tape[i]-=1;i-=1;i-=1;tape[i]+=1;while tape[i] != 0 do i+=1;end;i+=1;tape[i]-=1;end;i-=1;i-=1;print tape[i].chr;i-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;print tape[i].chr;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;tape[i]+=1;print tape[i].chr;print tape[i].chr;tape[i]+=1;tape[i]+=1;tape[i]+=1;print tape[i].chr;i-=1;i-=1;print tape[i].chr;i+=1;tape[i]-=1;print tape[i].chr;i+=1;print tape[i].chr;tape[i]+=1;tape[i]+=1;tape[i]+=1;print tape[i].chr;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;print tape[i].chr;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;tape[i]-=1;print tape[i].chr;i-=1;i-=1;tape[i]+=1;print tape[i].chr;i-=1;tape[i]+=1;tape[i]+=1;print tape[i].chr;

Mandelbrot

Input:

      A mandelbrot set fractal viewer in brainf*** written by Erik Bosman
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[
>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+
<<<<<<<+++++[-[->>>>>>>>>+<<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<<<<<<<[>[-]<-
>>>>>>>>[-<<<<<<<<+>[<->-<<+>>]<[->+<]>>>>>>>>]<<<<<<<[->>>>>>>+<<<<<<<]<+<<<<<<
<<<]>>>>>>>>-<<<<<[-]+<<<]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>->[>>>
>>>[->>+<<]>>>]<<<<<<<<<[>[-]<->>>>>>>>[-<<<<<<<<+>[<->-<<+>>]<[->+<]>>>>>>>>]<<
<<<<<[->>>>>>>+<<<<<<<]<+<<<<<<<<<]>+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>
+>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>[-<<<<<<->>>>>>]+<
<<<<<[->>>>>>->>[-<<<<<<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<<
<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>
-<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>
>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<++++
+[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<<
<<<<<]]>>>]

Output (I'm glad it isn't scored!) is available on Pastebin because it was too long to put here!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.