Skip to content

A language to transpile to brainfuck

License

Notifications You must be signed in to change notification settings

angrykoala/mindfck

Repository files navigation

mindfck

A simple language that transpiles to brainfuck:

int a
int b
a = 3 + a
a = 33 + a
a = a + 2
int c
a = a + 21
a = a + 2
b = 10 + a
c = a + b
print c

Transpiles to:

>>>>[-]>[-]+++<<<<<>>>>>>>>[-]<<[-]<<<<<<[>>>>>>+>>+<<<<<<<<-][-]>>>>>>>>[<<<<<<<<+>>>>>>>>-]><[-]<[-]<<<<<<[>>>>>>+>+<<<<<<<-][-]>>>>>>>[<<<<<<<+>>>>>>>-]><<<<<>>>>>>[-]<<[-]<<<<[>>>>+>>+<<<<<<-][-]>>>>>>[<<<<<<+>>>>>>-]><[-]<[-]<<<<[>>>>+>+<<<<<-][-]>>>>>[<<<<<+>>>>>-]><[-]<<<<[>>>>+<<+<<-][-]>>>>[<<<<+>>>>-]>[-]<[-]<<<[>>>+>+<<<<-][-]>>>>[<<<<+>>>>-]<[>[-]><<<+>>>>>[-]<[-]<<<<[>>>>+>+<<<<<-][-]>>>>>[<<<<<+>>>>>-][-]<<<[>>>+<-<<-][-]>>>[<<<+>>>-]<<[-]+>>>[-]<[-]<[>+>+<<-][-]>>[<<+>>-]<[<<[-]>>[-]][-]<[-]<[>+>+<<-][-]>>[<<+>>-]<[<<<<<+>>>>>[-]]<<<-]<<<<<<<<<<[-]>[-]>>>>>>><<<<<<<<[-]>>>>>>>>[<<<<<<<<+>>>>>>>>-]><<<<<<<<[-]>>>>>>>>[<<<<<<<<+>>>>>>>>-]><<<<<<[-]>[-]+++++++++++++++++++++++++++++++++<<<<<>>>>>>>>[-]<<[-]<<<<<<[>>>>>>+>>+<<<<<<<<-][-]>>>>>>>>[<<<<<<<<+>>>>>>>>-]><[-]<[-]<<<<<<[>>>>>>+>+<<<<<<<-][-]>>>>>>>[<<<<<<<+>>>>>>>-]><<<<<>>>>>>[-]<<[-]<<<<[>>>>+>>+<<<<<<-][-]>>>>>>[<<<<<<+>>>>>>-]><[-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<<<<<<<<<<<<->>>>>>>>[-]+>>>[-]<[-]<<<<<<<<<<<[>>>>>>>>>>>+>+<<<<<<<<<<<<-][-]>>>>>>>>>>>>[<<<<<<<<<<<<+>>>>>>>>>>>>-]<[<<[-]>>[-]]>[-]<[-]<<<<<<<<<<[>>>>>>>>>>+>+<<<<<<<<<<<-][-]>>>>>>>>>>>[<<<<<<<<<<<+>>>>>>>>>>>-]<[<<[-]>>[-]]<[-]+>>[-]<[-]<<[>>+>+<<<-][-]>>>[<<<+>>>-]<[<->[-]]<]<[-]++++++++++++++++++++++++++++++++++++++++++++++++>>[-]<[-]<<[>>+>+<<<-][-]>>>[<<<+>>>-]<[>[-]<<[>>+<<<+>-][-]>>[<<+>>-]<<<.>>[-]][-]+++>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>[-]>>>>>[-]<<[-]<<<<<<<<<<<<<<<<<[>>>>>>>>>>>>>>>>>+>>+<<<<<<<<<<<<<<<<<<<-][-]>>>>>>>>>>>>>>>>>>>[<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>-][-]<[-]<<<<<<[>>>>>>+>+<<<<<<<-][-]>>>>>>>[<<<<<<<+>>>>>>>-]<<<<[-]>[-]<<[-]>>>[<<+>>>[-<<<[-]>+>>]<<<[-<+>]>[->>+<<]>>-<-]<[-]<[-]<[>+>+<<-][-]>>[<<+>>-]<[<<<<<<<<<<<[-]+>>>>>>>>>>>[-]]>[-]<[-]<<<<<<<<<<<<<<<[>>>>>>>>>>>>>>>+>+<<<<<<<<<<<<<<<<-][-]>>>>>>>>>>>>>>>>[<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>-][-]<<<<[>>>>+<-<<<-][-]>>>>[<<<<+>>>>-]<<[-]+>>>[-]<[-]<[>+>+<<-][-]>>[<<+>>-]<[<<[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>>>[-]<[-]<[>+>+<<-][-]>>[<<+>>-]<[<<[-]>>[-]][-]<[-]<[>+>+<<-][-]>>[<<+>>-]<[>>>>>[-]<<[-]<<<<<<<<<<<<<<<<<[>>>>>>>>>>>>>>>>>+>>+<<<<<<<<<<<<<<<<<<<-][-]>>>>>>>>>>>>>>>>>>>[<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>-][-]<[-]<<<<<<[>>>>>>+>+<<<<<<<-][-]>>>>>>>[<<<<<<<+>>>>>>>-]<<<<[-]>[-]<<<<<<<<<<<<<[-]>>>>>>>>>>>>>>[<<+>>>[-<<<[-]>+>>]<<<[-<<<<<<<<<<<<+>>>>>>>>>>>>]>[->>+<<]>>-<-]<<<[-]][-]<[-]<<<<<<<<<<[>>>>>>>>>>+>+<<<<<<<<<<<-][-]>>>>>>>>>>>[<<<<<<<<<<<+>>>>>>>>>>>-]<[>[-]<<<<[>>>>+<<<<<<<<+>>>>-][-]>>>>[<<<<+>>>>-]<<<<<<<<.>>>>>>>[-]][-]<<<[>>>+<<<<<<<<+>>>>>-][-]>>>[<<<+>>>-]<<<<<<<<.

Usage

You need go to compile or run mindfck

Quickstart

go run . examples/abc.mf

To compile mindfck into a binary:

go build .

Once the compiler is ready, you can compile mindfck (.mf) files into brainfuck:

minfck examples/abc.mf

To compile and execute the brainfuck code directly:

minfck example.mf --run

FAQ

Q: Is this useful?
A: No
Q: Is it fun?
A: Also no

Features

  • Variables
    • Byte, can be assigned with numbers or char values
    • Int, unsinged 16-bit ints.
  • Math operations
  • Logical operations
  • If ... Else
  • While loops
  • Print and read bytes

Language Manual

Mindfck is heavily C-inspired, with a familiar syntax.

Variables

Mindfck supports 2 types of variables:

byte Stores a single byte

byte x
x = 'a'

Bytes can be assigned by passing a single character ('a') which will save the ascii value of that character. Alternatively, the exact byte number can be passed as a decimal integer with b: x = 10b

int Ints are unsigned 16bit integers

int a
a = 10

I/O

print is supported for bytes and integers. bytes will be printed as a single character. ints will be printed as decimal numbers.

print 10
print 'a'

read is only supported for bytes, allowing to store a byte in a variable.

Conditionals

If ... else flows are supported:

if(x == 'a'){
    print 'a'
} else {
    print 'b'
}

Loops

while can be used with a simple condition to loop.

byte letter
letter = 'a'
while (letter < z) {
    print letter
    letter = letter + 1
}

Mathematical operators

The following mathematical operators are supported for int operations:

  • +
  • -
  • /
  • *

Logical operators

  • and
  • or
  • ! or not

Comparison operators

  • ==
  • >
  • >=
  • <
  • <=

Development Instructions

Mindfck is written in go.

Build

go build .

Run

go run .

Tests

go test ./...

Grammar

Grammar is written in antlr4 (parser/mindfck.g4). If it is updated, files need to be regenerated.

Install antlr4-tools to work with the parser

pip3 install antlr4-tools

You'll also need java-11-jre or openjdk-11-jre installed

To regenerate the parser, do:

go generate

This will execute antlr4, equivalent to: antlr4 parser/antlr/mindfck.g4 -Dlanguage=Go

To parse something manually in the command line:

antlr4-parse parser/antlr/mindfck.g4 statements -gui

Alternatively:

        curl https://www.antlr.org/download/antlr-4.13.0-complete.jar --output antlr4.jar
        mkdir -p $HOME/.local/bin
        echo -e "#bin/bash\njava -jar $PWD/antlr4.jar \$@" > $HOME/.local/bin/antlr4
        chmod a+x $HOME/.local/bin/antlr4

To debug the gramar: Antlr Lab

Resources

These resources where used as inspiration / tools for this project

About

A language to transpile to brainfuck

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published