Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Discookie/bf-to-turing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Brainfuck IR to Turing Machine compiler

This little program compiles Brainfuck IR outputted by bfc to Turing Machine code accepted by Turing Machine Simulator.

The compiled code is not that quick, it contains a lot of repeat instructions. This is more of a proof-of-concept that it can be done.

It currently requires JSON-formatted BFIR, but 'raw' BFIR parsing is on the way. A bfc variant which supports this can be obtained via here.

Instructions

  • The byte values from 0 to 255 are mapped to characters, which are printed into the output
  • Read (,) operations are not supported
  • Write (.) operations do the following:
    • If a 0 is written, the program jumps into the 'end' accepting state.
    • If a 'normal' (33 <= x < 127) ASCII character is written, execution continues.
    • Otherwise, execution stops in a rejected state.
  • If the --two-tape flag is specified, 'normal' ASCII characters are printed onto the second tape, from left to right.
    • Printing empty spaces is currently not supported

Example commands

$ bfc example.bf --dump-ir-json | bf-to-turing > example.txt
$ bfc example.bf --dump-ir-json | bf-to-turing --two-tape > example.txt

License

GPLv3 or later license. Uses bfir.rs from bfc, which is under GPLv2 or later license.

About

A proof-of-concept Brainfuck to Turing Machine compiler

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages