BFFuck

From Esolang
Jump to navigation Jump to search

BFFuck is a high-level language that compiles to brainfuck, its goal is to make programming in brainfuck easier.

Introduction

BFFuck is created by User:None1, made to make programming in brainfuck easier. It is a work in progress (but still quite powerful). It uses many algorithms in brainfuck algorithms.

Its compiler is in Python, and therefore supports any platform.

It runs on 8 bit cells with wrapping.

How to compile

To compile a program, you run this in python:

from bffuck import BFFuck
bff=BFFuck()
bf=bff.compile('program')
print(bf)

Syntax

It currently has the following syntax (note that in the text below, x denotes either a variable or number and a denotes a variable):

# Comment
a=in # Read an integer and store in a
a=inc # Read a character and store its ASCII value into a
out(x) # Output value of x as integer
outc(x) # Output value of x as ASCII character
a=x # Copies value of x to a
print(STRING) # Output STRING without linefeed(STRING does not need to be surrounded by quotes).
add(a,x) # Adds a and x and stores it into a
sub(a,x) # Subtracts a and x and stores it into a
mul(a,x) # Multiplies a and x and stores it into a
mod(a,x) # Set a to a mod x
lt(a,x) # If a is less than x, set a to 1, otherwise 0
eq(a,x) # If a is equal to x, set a to 1, otherwise 0

while(x)
CODE
endwhile # While loop, can be nested.

if(x)
CODE
endif # One-branch if statement, can be nested.

if(x)
CODE1
else
CODE2
endif # Two-branch if-else statement, can be nested.

macro $<name> # Macro with no arguments
CODE
endmacro

macro $<name>(<arg1>,<arg2>,...) # Macro with arguments
CODE
endmacro

$<name> # Using a macro with no arguments
$<name>(<arg1>,<arg2>,...) # Using a macro with arguments

ptr(a,b) # Store address of a to variable b
ref(a,b) # Store address b to a
set(a,b) # Set address b to a

?libraryname # Includes a library

P.S.: It is case sensitive, and numbers, in and inc are not supposed to be variable names. Addresses must have the same parity as the playfield and must be larger than the playfield, Accessing, setting a variable's own address with the variable (e.g.: set(a,b)) when b is the address of a) is undefined behavior. Comments aren't allowed yet after the declaration of a macro or the include of a library.

Examples

Hello World

print(Hello World!)

You'll get the following brainfuck code if you compile it:

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

Cat Program

while(1)
x=inc
outc(x)
endwhile

You'll get the following brainfuck code if you compile it:

>>>>>>>>>>+[>,.<]

A+B Problem

x=in
y=in
add(x,y)
out(x)

You'll get the following brainfuck code if you compile it:

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

Fibonacci sequence

a=0
b=1
c=14
d=0
while(c)
sub(c,1)
add(d,a)
add(d,b)
out(a)
outc(10)
a=b
b=d
d=0
endwhile

It probably requires "playfield" to have length of at least 15, and you'll get the following brainfuck code if you compile it:

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

Truth Machine

a=in
if(a)
while(1)
out(1)
endwhile
endif
out(0)

You'll get the following brainfuck code if you compile it:

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

Recite the alphabet

a=65
b=26
while(b)
outc(a)
add(a,1)
sub(b,1)
endwhile

You'll get the following brainfuck code if you compile it:

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

Deadfish interpreter

e=0
while(1)
print(> )
c=inc
f=inc # "Eats" the trailing line feed
d=105
eq(d,c)
if(d)
add(e,1)
endif
d=100
eq(d,c)
if(d)
sub(e,1)
endif
d=115
eq(d,c)
if(d)
g=e
mul(e,g)
endif
d=111
eq(d,c)
if(d)
out(e)
outc(10)
endif
endwhile

You'll get the following brainfuck code if you compile it:

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

brainfuck interpreter

c=inc
d=0
sub(c,10)
while(c)
eq(c,33)
if(c)
add(d,1)
endif
c=inc
sub(c,10)
endwhile
outc(d)

You'll get the following brainfuck code if you compile it:

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

XKCD Random Number

out(4)
# Chosen by fair dice roll
# Guaranteed to be random

You'll get the following brainfuck code if you compile it:

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

brainfuck interpreter

x=inc
z=1
t=x
y=10
eq(t,y)
sub(z,t)
while(z)
eq(x,91)
if(x)
z=0
endif
if(z)
x=inc
t=x
eq(t,y)
sub(z,t)
endif
endwhile

You'll get the following brainfuck code if you compile it:

>>>>>>>>>>>>>>>,>[-]+>[-]<<[>>+<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<<[>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>>>>>[-]++++++++++<<<<[-]<[-]>>>>[<<<<+>>>>-]+>[<<<<<->+>>>>-]<<<<[>>>>+<<<<-]<[>>>>-<<<<[-]]>[-]>>>[<-<<+>>>-]<<<[>>>+<<<-]>>[<<+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++[-]<[-]>>[<<+>>-]+<<<[>->+<<-]>>[<<+>>-]<[>>-<<[-]]<[-]>>[-]<[-]>>[<+<+>>-]<[>+<-]<[>>>[-]<<<[-]]>[-]<[-]>>>[<<+<+>>>-]<<[>>+<<-]<[>>,>>[-]<<[>>+<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<<[>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>[-]<[-]>>>>[<<<<+>>>>-]+>[<<<<<->+>>>>-]<<<<[>>>>+<<<<-]<[>>>>-<<<<[-]]>[-]>>>[<-<<+>>>-]<<<[>>>+<<<-]<[-]]>>>]

pRINT interpreter

x=inc
sub(x,10)
while(x)
eq(x,102)
if(x)
print(print)
outc(10)
endif
x=inc
sub(x,10)
endwhile

You'll get the following brainfuck code if you compile it:

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

Fuck you! interpreter

It only interprets the first line of input.

x=inc
sub(x,10)
while(x)
eq(x,23)
if(x)
print(Fuck you!)
outc(10)
endif
x=inc
sub(x,10)
endwhile

You will get the following brainfuck code if you compile it:

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

FizzBuzz

i=1
a=101
b=1
eq(a,i)
sub(b,a)
while(b)
	t=i
	mod(t,3)
	u=i
	mod(u,5)
	if(t)
		if(u)
			out(i)
		else
			print(Buzz)
		endif

	else
		if(u)
			print(Fizz)
		else
			print(FizzBuzz)
		endif
        endif
	outc(10)
	add(i,1)
	a=101
	b=1
	eq(a,i)
	sub(b,a)
endwhile

You'll get the following brainfuck code if you compile it:

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

Reason why creating it

Currently, I'm intrested in brainfuck code generation, so I tried many tools including BFBASIC,C2BF and FBP, but:

  • BFBASIC echoes the input and stores the wrong input when you use the input command.
  • C2BF's source code failed to compile in Windows.
  • FBP doesn't have input?!

So, I created my own brainfuck code generator.

How it works

Programs compiled by BFFuck uses several starting bytes of memory (the number can be customized but should not be too small, default is 15, but in some cases it can even be 0) as temporary memory known as "playfield" (The name comes from "playfield" in Befunge, but that works very differently), and stores its variables in bytes right after the "playfield".

The decimal output algorithm used in the compiler uses an unknown number of cells, so be careful with using the out command because that command might overwrite the variables if the length of "playfield" is not enough. If you found something wrong while using that command, you can try increasing length of playfield simply by passing an argument to BFFuck()

In some cases, BFFuck uses an imaginary variable named "0". That variable's address changes dynamically.

How to help about the project

You can help in the follwing 3 ways:

  • Invent new algorithms in brainfuck algorithms.
  • If you found a bug or have any advice (or a question), post an issue at GitHub or write in the talk page.
  • Collaborators are welcomed, if you want to collaborate, write in the talk page. (Please also write your GitHub/PyPI account to the talk page if you have one.)

External Resources

  • The source code of the compiler in Python at GitHub, along with some examples.
  • The same source code at Gitee.
  • Try it online!, supports adding one extra command line argument to change length of "playfield".
  • PyPI Link, therefore you can install it using pip install BFFuck (note that the versions before 2.0.0 have bad markup because the author forgot to set long_description_content_type to text/markdown)

You've read the documentation of BFFuck! Now you can enjoy it! :D

See also