|Number of watchers on Github||205|
|Number of open issues||0|
|Average time to close an issue||about 1 year|
|Open pull requests||0+|
|Closed pull requests||0+|
|Last commit||about 4 years ago|
|Repo Created||almost 7 years ago|
|Repo Last Updated||over 2 years ago|
|Organization / Author||matslina|
|Do you use awib? Leave a review!|
|View awib activity|
|View on github|
|Book a Mock Interview With Me (Silicon Valley Engineering Leader, 100s of interviews conducted)|
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Awib is a brainfuck compiler entirely written in brainfuck.
Feed awib brainfuck source code as input and the compiled program will be written as output.
Awib is a cross-compiler. The supported target platforms are
listed below. By default, the target
lang_c is chosen.
To specify a target platform, insert a line on the form
(without the quotation marks and with
TARGET suitably replaced)
at the very beginning of the source code you wish to compile.
Awib will then produce output accordingly.
386_linux - Linux executables for i386 lang_c - C code lang_ruby - Ruby code lang_go - Go code lang_tcl - Tcl code lang_java - Java code
For instance, the following input would produce an executable hello world-program for Linux:
@386_linux ++++++[->++++++++++++<]>.----[--<+++>]<-.+++++++..+++.[--->+<]>-----.-- -[-<+++>]<.---[--->++++<]>-.+++.------.--------.-[---<+>]<.[--->+<]>-.
The following would produce a hello world-program in Ruby:
@lang_ruby ++++++[->++++++++++++<]>.----[--<+++>]<-.+++++++..+++.[--->+<]>-----.-- -[-<+++>]<.---[--->++++<]>-.+++.------.--------.-[---<+>]<.[--->+<]>-.
And this file would give you the hello world-program in C:
@lang_c ++++++[->++++++++++++<]>.----[--<+++>]<-.+++++++..+++.[--->+<]>-----.-- -[-<+++>]<.---[--->++++<]>-.+++.------.--------.-[---<+>]<.[--->+<]>-.
Awib is an optimizing compiler:
----is replaced with a single SUB(4).
+++-->><is equivalent to
+>and is compiled accordingly.
[-]is compiled into a single SET(0).
[->>+++ is compiled into two RMUL(2, 3), RMUL(1,1)), SET(0)..
Awib will run smoothly in any brainfuck environment where:
The vast majority of brainfuck environments meet these criteria.
Since awib is polyglot, it is also possible to compile and/or run awib directly as C, tcl or bash. For instance, using gcc, the following will build an executable file called awib from awib-0.2.b.
$ cp awib-0.2.b awib-0.2.c $ gcc awib-0.2.c -o awib.tmp $ ./awib.tmp < awib-0.2.b > awib-0.2.c $ gcc -O2 awib-0.2.c -o awib
Using bash works fine, but is very very very slow:
$ (echo "@386_linux"; cat awib.b) | bash awib.b > awib $ chmod +x awib
$ (echo "@386_linux"; cat awib.b) | tclsh awib.b > awib $ chmod +x awib
Code compiled with awib will execute in an environment where:
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Mats Linander, 2014-09-14