Skip to content

ClementTsang/brainfC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

brainfC

A Brainf**k <=> C transpiler.

Note the code I write is probably not the prettiest or best practice Go... I'm quite new to this language, hopefully this will improve as this project progresses.

Instructions to Install

Clone the repo into your Go path. Go to the cloned repo directory and run the makefile.

Features (so far)

  • Convert from BF to somewhat optimized (but not really) C code
    • Optimizations include:
      • Peephole optimization
      • Duplicate instruction optimization
  • Convert from (a subset of) C to BF
    • Current C syntax that is supported:

Usage

To convert BF to C in command line, for example:

./brainfC -c ./examples/bf_samples/hello_world/hello_world.bf

Likewise, to convert C to BF in command line:

./brainfC -b ./examples/c_samples/hello_world/hello_world.c

If you want to interpret the resulting BF code, use something like Beef.

Demo

An online demo can be seen here.

Contribution

If you spot a bug/typo/issue and/or want to contribute, let me know.

Why...?

Why not?

It was mostly an interesting way to apply what I've learned in compiler design from class (a bunch of what I learned carried over), as well as try to use Go, albeit in a way that was neither really productive or practical.

Credits/Thanks

Bunch of resources/projects I have to give thanks to.