NAME

nbfc -- The new brainfuck compiler


SYNOPSIS

nbfc [options] file


DESCRIPTION

nbfc is a new, completely portable compiler for the brainfuck programming language. It will generate and compile C code or as an option a Java application.

nbfc is quite different from the original brainfuck compiler by the language's inventor Urban Mueller:

- It's portable. The original bfc was for the Amiga only. nbfc should run on any unix-like system.
- It uses standard tools for its implementation and doesn't try to obfuscate the code.
- It can compile to C and supports the ''write once, run anywhere'' concept with its capability to generate Java applications.


OPTIONS

-o file

Generate an executable by the name of file. If the -j switch is given, this will be the name of the Java Class generated.

-k

Keep generated intermediate code (C or Java). The default is to delete the .c or .java file that was generated by the compiler and just keep the executable or the .class file, respectively.

-j

Generate and compile a Java class instead of a C executable. The default is to use C as an intermediate language.

-v

Be verbose. By invoking this switch, nbfc will print out lots of messages about the state of compilation.

-g

Don't compile, just generate intermediate file (C or Java). This can be used for debugging. This also tells the compiler no to delete the generated intermediate file, as if the -k option was given.

-c

Display the copying license. The license is BSD-style and very liberal.

-h

Display a short help screen.


INVOCATION

When called without any options, nbfc will translate the brainfuck file given on the command line to C and call a C compiler to produce an executable.

The executable will have the name bf.out (this can be changed with the -o option). The intermediate C file always has the name bf.out.c and will be deleted if the -k option is not present.

When using Java as the intermediate language, the default name for the application is bf.out.class, the default name for the Java file is bf.out.java. Both the class name and the intermediate Java code file name can be changed with the -o option.


THE LANGUAGE

brainfuck is a simple enough language to include the entire official language describtion in this man page. The following is from the original brainfuck distribution by Urban Mueller <umueller@amiga.physik.unizh.ch>, who also invented the language:

''The language brainfuck knows the following commands:

 Cmd  Effect                                 Equivalent in C
 ---  ------                                 ---------------
 +    Increases element under pointer        array[p]++;
 -    Decrases element under pointer         array[p]--;
 >    Increases pointer                      p++;
 <    Decreases pointer                      p--;
 [    Starts loop, counter under pointer     while(array[p]) {
 ]    Indicates end of loop                  }
 .    Outputs ASCII code under pointer       putchar(array[p]);
 ,    Reads char and stores ASCII under ptr  array[p]=getchar();

All other characters are ignored. The 30000 array elements and p are being initialized to zero at the beginning. Now while this seems to be a pretty useless language, it can be proven that it can compute every solvable mathematical problem (if we ignore the array size limit and the executable size limit).''


BUGS

There is no checking for balanced brackets; if these are not balanced, strange things may happen. The compiler doesn´t optimize. There really should be a backend that generates assembly language code (at least for Intel and PowerPC machines) instead of only C and Java.


AUTHOR

Jens Ohlig <jo@koeln.ccc.de>