Skip to main content

Downloads Downloads Downloads

BFFuck

Makes brainfucking easier

The tools is an esoteric language that compiles to brainfuck, using algorithms in brainfuck algorithms.

Usage:

Run this in Python:

from bffuck import BFFuck
bff=BFFuck()
bf=bff.compile('Your code')

Note that if a BFFuck object is created and used, its status will change and therefore cannot compile another program.

Syntax

BFFuck currently supports the following syntax:

Comment:

# Comment

Raw brainfuck code injection:

bf "BF code" # Raw BF code injection

Variable definition:

<variable 1>=<variable 2>
or
<variable>=<number>

Move instruction:

a->b
b<-a
# These two do the same thing:
# They move the value of a to b (overwriting b's value, and make a 0)
# The same as a=b<LF>b=0, but does point-to-point movement between *existing variables*
# so it's both shorter and faster

Addition:

add(x,<number>)
or
add(x,<variable>)

Subtraction:

sub(x,<number>)
or
sub(x,<variable>)

Multiplication:

mul(x,<number>)
or
mul(x,<variable>)

Modulo:

mod(x,<number>)
or
mod(x,<variable>)

While loop:

while(<variable or number>)
CODE
endwhile

I/O:

<variable>=in # Reads <variable> as decimal integer
<variable>=inc # Reads <variable> as ASCII character
out(<variable or number>) # Outputs <variable> as decimal integer
outc(<variable or number>) # Outputs <variable> as ASCII character

String output shortcut:

print(STRING) # Without quotes
# For instance
print(Hello World!)

If statement:

if(<variable or number>)
CODE
endif

if(<variable or number>)
CODE1
else
CODE2
endif

Comparison:

lt(x,<number>) # Compares x and the variable or number, if x is less than the variable or number, set x to 1, otherwise 0
or
lt(x,<variable>)

eq(x,<number>) # Compares x and the variable or number, if x is equal to the variable or number, set x to 1, otherwise 0
or
eq(x,<variable>)

Macros:

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

Memory:

ptr(a,b) # Store address of a to variable b
ref(a,b) # Store value of address b to variable a
set(a,b) # Set value of address b to a (variable or integer literal)

Libraries

?libraryname

Includes the library library name (with file extension).

It first searches the library in current directory, and then in the stdlib directory in the package.

There are standard libraries for BFFuck, they are:

  • env.bff gets size of a "byte" specified by the compiler
  • alloc.bff allocates memory
  • array.bff manages memory using arrays
  • rng.bff a not very decent random number generator

An example of the rng.bff library is here:

?rng.bff
x=0
while(1)
$rnd(x)
outc(x)
endwhile

Prints random bytes.

Platform

BFFuck is in pure Python and therefore it supports any platform.

Constraints

Programs compiled from BFFuck needs you to have 8 bit cells that wrap.

Disadvantages

BFFuck currently has these disadvantages:

  1. It's numbers are 8 bit numbers. You can choose 8-bit, 16-bit or 32-bit numbers using the byte keyword argument. But you need to run it on a 8-bit interpreter. REMEMBER: Using numbers with more bits is slower and increases the size of program largely! If you're using 32 bit, remember to use an extremely optimizing interpreter like bffsree!
  2. It has some bugs.

The repository contains some examples, including a Hello World program, a cat program and an A+B program.

Metadata

Release files for bffuck 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bffuck 3.1.0
File Size Uploaded
bffuck-3.1.0.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bffuck 3.1.0
File Interpreter ABI Platform
bffuck-3.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.0 kB

Release files / bffuck-3.1.0.tar.gz

Download URL bffuck-3.1.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c5c9238d32f4596274be014d4e910e039af57ecb90ed7ec81e41ba41a96e7b2c
BLAKE2b-256 checksum
How to use checksums
eb829160c854ecc118129c2fd341b804d5bbc0b9134883204fbb9655d33b32f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.0

Release files / bffuck-3.1.0-py3-none-any.whl

Download URL bffuck-3.1.0-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b6e6849705ab4b39d8f4e767f1ef8462dd160b15163260a170e820cc69170ec
BLAKE2b-256 checksum
How to use checksums
aa468e77cb24ad5cead583e771ecb8a4edf5cf50d2511dd96295fed83ed650f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.0

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 release files

3.0.6

2 release files

3.0.5

2 release files

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page