nbfc -- The new brainfuck compiler
nbfc [options] file
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:
Generate an executable by the name of file. If the -j switch is given, this will be the name of the Java Class generated.
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.
Generate and compile a Java class instead of a C executable. The default is to use C as an intermediate language.
Be verbose. By invoking this switch, nbfc will print out lots of messages about the state of compilation.
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.
Display the copying license. The license is BSD-style and very liberal.
Display a short help screen.
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.
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).''
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.
Jens Ohlig <jo@koeln.ccc.de>