A compiler and interpreter for Brainf-ck. Due to the JVM's widely recognized JIT capabilities, Brainf-ck code compiled with jf-ck is likely to be as fast as C in some situations. Even if your code happens to be a smidge slower than C, this is typically acceptable as writing anything significant in Brainf-ck is nigh impossible.
- Cells are 8 bit, wrapping
- 231 - 1 cells, starting from 0
,
returns 0 on EOF
- Clone the repo.
./gradlew shadowJar
java -jar build/libs/jf-ck-1.0-SNAPSHOT-all.jar [-i] <filename>
jf-ck defaults to compilation. The input is a single file, or stdin if the filename is -
. If you are cracked in the head and want to compile a file named -
, maybe try java -jar build/libs/jf-ck-1.0-SNAPSHOT-all.jar - < -
. The output is a single class file, named aout.class
, written to the current directory.
The option -i
causes jf-ck to enter interpretive mode, which is quite sophisticated and employs an anonymous inner classloader. The author is quite proud of what he did there, both the hack and the sort-of-punny name for it.
Yes, you can do this. byte[] us.abbies.b.jfck.Compiler.compile(String)
will compile Brainf-ck code into class bytes. Loading them is the caller's problem; an anonymous inner classloader may be useful here. The compiled class implements Runnable
and that's all you can do with it.
None are known.