Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ClementTsang/brainfC
A WIP Brainf**k <=> C transpiler.
https://github.com/ClementTsang/brainfC
brainfuck brainfuck-transpiler c go transpiler
Last synced: 29 days ago
JSON representation
A WIP Brainf**k <=> C transpiler.
- Host: GitHub
- URL: https://github.com/ClementTsang/brainfC
- Owner: ClementTsang
- License: mit
- Created: 2019-07-03T02:53:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-03T03:44:57.000Z (over 5 years ago)
- Last Synced: 2024-10-14T19:43:57.808Z (about 2 months ago)
- Topics: brainfuck, brainfuck-transpiler, c, go, transpiler
- Language: Go
- Homepage:
- Size: 1.16 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - brainfC
README
# 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:
```bash
./brainfC -c ./examples/bf_samples/hello_world/hello_world.bf
```Likewise, to convert C to BF in command line:
```bash
./brainfC -b ./examples/c_samples/hello_world/hello_world.c
```
If you want to interpret the resulting BF code, use something like [Beef](https://kiyuko.org/software/beef).# Demo
An online demo can be seen [here](https://clementtsang.github.io/brainfC/).
## 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.* I referred to the source code of [c2bf](https://github.com/arthaud/c2bf) a lot for the C => component.
* Some BF code samples in the [examples](./examples) directory was sourced from the [Brainf\*\*k Wikipedia article](https://en.wikipedia.org/wiki/Brainfuck).
* Many of the BF algorithms used for converting from C to BF were sourced from the [Esolangs wiki for Brainf\*\*k](https://esolangs.org/wiki/Brainfuck_algorithms).
* yacc code for C to BF was based on [the yacc file from this website](http://www.quut.com/c/ANSI-C-grammar-y.html), and the lexer was based on [this page from the same website](http://www.quut.com/c/ANSI-C-grammar-l-2011.html).