Skip to content

A language to transpile to brainfuck

License

Notifications You must be signed in to change notification settings

angrykoala/mindfck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mindfck

A simple language that transpiles to brainfuck:

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

Transpiles to:

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

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
  • Math operations
  • Logical operations
  • If ... Else
  • While loops
  • Print and read bytes

Development

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

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