Skip to main content

Makes Brainfucking Easier!

Project description

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

Variable definition:

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BFFuck-3.0.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

BFFuck-3.0.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file BFFuck-3.0.0.tar.gz.

File metadata

  • Download URL: BFFuck-3.0.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.0

File hashes

Hashes for BFFuck-3.0.0.tar.gz
Algorithm Hash digest
SHA256 60e6aadfa2fba1d99727e44a1c29496ef086ebac444c1d710dd30faae416d0b3
MD5 9e30940c4fdf8983b0740580bbbfc54d
BLAKE2b-256 ff15c194b93ba5c31a6e71ecddecddfc56b85dd1a0dd5e261e898fd92a1e7b0b

See more details on using hashes here.

File details

Details for the file BFFuck-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: BFFuck-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.0

File hashes

Hashes for BFFuck-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ff292d88dd595e2ee2d08eb89ef859124aa443272c80f940572f1a5a4bc78e9
MD5 50f0339252a5c888142988bc83e39513
BLAKE2b-256 83cabd3a9ba81d9856a47af89cdb82a993c71d32bc476327e6b4875736c02f37

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page